Description
Consider the following:
trait Foo {
fn foo();
}
impl Foo for () {
fn foo() { }
}
fn main() {
(&() as &Foo).foo();
}
The error is:
error: type `&Foo<no-bounds>` does not implement any method in scope named `foo`
The reason trait types do not automatically implement their own traits is that if the trait interface has a Self type variable, it does not make sense for it to be called in a heterogeneous way (e.g., if instantiating fn eq(&self, other: &Self)
with int-as-Eq as the first thing, it makes no sense to pass a str-as-Self as the second.
But if the trait has no such problematic interface functions, it should (apparently doesn't yet, but should in the future -- @nikomatsakis) be possible for the user to write an impl with stub methods that do dynamic dispatch.
So, I wish for either (a) a special-case span_note that accompanies this error that instructs the user to write stubs, or (b) recognising a non-problematic trait interface that can be auto-implemented, permitting that, and having a special-case span_note that explains why not in the problematic case.