Skip to content

Fehler didn't support returning Result<Box<dyn Trait>, _> #55

@earthengine

Description

@earthengine

Code:

use fehler::throws;

trait FooTrait {}
struct FooStruct;
struct FooError;
impl FooTrait for FooStruct {}
#[throws(FooError)]
fn foo() -> Box<dyn FooTrait> {
    Box::new(FooStruct)
}

Compile result:

Error[E0271]: type mismatch resolving ...
    |
104 | #[throws(FooError)]
    | ^^^^^^^^^^^^^^^^^^^^^^ expected trait object `dyn mymodule::FooTrait`, found struct `mymodule::FooStruct`
    |
    = note: expected type `std::boxed::Box<dyn mymodule::FooTrait>`
             found struct `std::boxed::Box<mymodule::FooStruct>`
    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions