Skip to content

Error calling supertrait method via trait reference  #4295

Closed

Description

trait A {
    fn foo();
}

trait B: A {
}

struct BImpl {
    unused: int
}

impl BImpl: B {
}

impl BImpl: A {
    fn foo() {}
}

struct CImpl {
    b: B
}

impl CImpl: A {
    fn foo() {
        self.b.foo();
    }
}

fn main() {
    let b = BImpl { unused: 0 } as B;
    let c = CImpl { b: b };
    c.foo();
}
[jdm@rosencrantz traitinheritance]$ rustc test2.rs 
test2.rs:25:8: 25:21 error: type `@B` does not implement any method in scope named `foo`
test2.rs:25         self.b.foo();
                    ^~~~~~~~~~~~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Assignees

No one assigned

    Labels

    A-traitsArea: Trait system

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions