Skip to content

Support traits defined in crate #1

@schneidersteve

Description

@schneidersteve

I extended the 3_inject_options_list.rs example to implement Interface4 from crate test_def.

use test_def::Interface4;

#[provides]
impl Interface4 for Comp {
    fn int4(&self) {
        println!("Interface 4");
    }
}

I get the following compiling error:

cargo run --color=always --package waiter_di --example 3_inject_options_list
   Compiling waiter_di v1.6.4 (/home/steve/workspaces/playground/rust/waiter)
error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
   --> examples/3_inject_options_list.rs:116:1
    |
116 | #[provides]
    | ^^^^^^^^^^^
    | |
    | impl doesn't use only types from inside the current crate
    | `waiter_di::Container` is not defined in the current crate
    | `dyn Interface4` is not defined in the current crate
    |
    = note: define and implement a trait or new type instead
    = note: this error originates in an attribute macro (in Nightly builds, run with -Z macro-backtrace for more info)

error: aborting due to previous error

For more information about this error, try `rustc --explain E0117`.
error: could not compile `waiter_di`

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