Closed
Description
Some newcomers are confused by impl Trait
in return position because they have first internalized impl Trait
as an alias for type parameters in argument position. Because of this, some people try the following:
trait Trait {}
impl Trait for () {}
// this works
fn foo() -> impl Trait {
()
}
// this doesn't
fn bar<T: Trait>() -> T {
()
}
We don't currently point them in the right direction, like we do in other cases.
Took inspiration from https://twitter.com/JaapRood/status/1400782159812628482
Metadata
Metadata
Assignees
Labels
Area: Messages for errors, warnings, and lintsArea: `impl Trait`. Universally / existentially quantified anonymous types with static dispatch.Area: Suggestions generated by the compiler applied by `cargo fix`Diagnostics: Confusing error or lint; hard to understand for new users.Diagnostics: An error or lint that needs small tweaks.Low priorityRelevant to the compiler team, which will review and decide on the PR/issue.