Skip to content

error: the trait Foo is not implemented for the type Box<Bar> #18179

Closed
@tomaka

Description

@tomaka

This code:

trait Foo {
    fn do_foo(&self);
}

trait Bar {
    fn do_bar(&self);
}

impl<T> Bar for T where T: Foo {
    fn do_bar(&self) {
        self.do_foo()
    }
}

struct Obj {
    obj: Box<Bar + 'static>
}

impl Obj {    
    fn process(&self) {
        self.obj.do_bar();
    }
}

(http://is.gd/hTCzJI)

Produces:

<anon>:21:9: 21:26 error: the trait `Foo` is not implemented for the type `Box<Bar>`
<anon>:21         self.obj.do_bar();

I think that this kind of code used to work in the past, so it could be a regression.
Even if this code is not supposed to work, the error message makes no sense.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions