Skip to content

Type checker is not aware that impl Trait for T implies that T:Trait #7933

Closed
@pkgw

Description

@pkgw

At least, that's my naive take on what's going on. This example doesn't compile for me, while it seems to me like it should:

pub trait Super { }

pub trait Main {
    fn callreflect<T: Reflector> (&self, v: T);
}

pub trait Reflector {
    fn reflect<T: Main> (&self, h: &T);
}

impl<S: Super> Main for S {
    fn callreflect<T: Reflector> (&self, v: T) {
        v.reflect (self);
    }
}

I get:

testcase.rs:13:8: 13:25 error: failed to find an implementation of trait Main for S
testcase.rs:13         v.reflect (self);

Seeing as this error is in fact triggered inside the implementation of Main, it seems bogus to me. Or am I missing something?

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