Better error message for why ~/@/&Trait doesn't automatically implement Trait #7914
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-trait-system
Area: Trait system
A-type-system
Area: Type system
Consider the following:
The error is:
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.
The text was updated successfully, but these errors were encountered: