-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Error message for type mismatch between impl Traits needs better explanation #57266
Copy link
Copy link
Closed
Closed
Copy link
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`A-type-systemArea: Type systemArea: Type systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Metadata
Metadata
Assignees
Labels
A-diagnosticsArea: Messages for errors, warnings, and lintsArea: Messages for errors, warnings, and lintsA-impl-traitArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.A-suggestion-diagnosticsArea: Suggestions generated by the compiler applied by `cargo fix`Area: Suggestions generated by the compiler applied by `cargo fix`A-type-systemArea: Type systemArea: Type systemT-compilerRelevant to the compiler team, which will review and decide on the PR/issue.Relevant to the compiler team, which will review and decide on the PR/issue.
Type
Fields
Give feedbackNo fields configured for issues without a type.
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 Traitis likedyn Traitand 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 --explaindocument.If possible, instead of "(opaque type)" print more internal type information, e.g. like for closures: