Error message for type mismatch between impl Traits needs better explanation #57266
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
A-impl-trait
Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.
A-suggestion-diagnostics
Area: Suggestions generated by the compiler applied by `cargo fix`
A-type-system
Area: Type system
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
The message "expected type
impl Trait
(opaque type), found typeimpl Trait
(opaque type)" sounds like a paradox: the compiler has found exactly what it expected, and yet it doesn't match.The explanatory text of E0308 is the same as for all other banal type errors, so it's not addressing this problem specifically.
From the questions I'm seeing in the user forum I have an impression that users think
impl Trait
is likedyn Trait
and try to use it as an abstraction for mixing different types.Suggestions:
Make it a separate error, so that it'll get its own
rustc --explain
document.If possible, instead of "(opaque type)" print more internal type information, e.g. like for closures:
The text was updated successfully, but these errors were encountered: