Detect type parameters that were meant to be impl Trait
in return position
#78906
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
D-newcomer-roadblock
Diagnostics: Confusing error or lint; hard to understand for new users.
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given
fn foo<T: Any>() -> T { "" }
the output is:We should be suggesting the use of
impl Trait
while explaining that the callers offoo
will only be able to access whatever the trait bounds allow:fn foo() -> impl Any { "" }
. We should also likely add an additional note for the special case of anAny
bound letting people know that it is very unlikely what they want to do.(Taken from a subset of https://users.rust-lang.org/t/how-can-we-return-a-anonymous-type-in-result-trait/51258)
The text was updated successfully, but these errors were encountered: