-
-
Notifications
You must be signed in to change notification settings - Fork 14.7k
E0562 should mention impl Trait in argument position #80476
Copy link
Copy link
Closed
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.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-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.C-bugCategory: This is a bug.Category: This is a bug.D-incorrectDiagnostics: A diagnostic that is giving misleading or incorrect information.Diagnostics: A diagnostic that is giving misleading or incorrect information.D-papercutDiagnostics: An error or lint that needs small tweaks.Diagnostics: An error or lint that needs small tweaks.T-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.
impl Traitas a type is permitted in function parameter lists. However, the error message E0562 incorrectly states that it is only permitted in function or inherent method return positions.Being precise in this message will assist beginners (such as myself a few months ago) in understanding the boundaries of the language. Particularly, one might reasonably imagine equivalence between a function's parameter list and a single parameter whose type is a
structbundling several parameters, butimpl Traitis available in the former and not the latter — whereas the error message implies that it is allowed in neither of those places.Tangentially, it would be neat if the compiler gave suggestions to rewrite disallowed
impl Traitas either an explicit parameter,struct C<S: impl Into<String>> { x: S }, or (especially in the case ofimpl Into) a constructor function, but that's much more work and more dependent on the context and perhaps even the specific trait.Meta
This occurs on both stable
1.48.0and nightly1.50.0-nightly (2020-12-22 bb1fbbf84455fbad9afd), and the message is present in the same form in the current source code.