rustc should recommend impl Trait before dyn Trait in argument and return type positions #99304
Labels
A-diagnostics
Area: Messages for errors, warnings, and lints
T-compiler
Relevant to the compiler team, which will review and decide on the PR/issue.
Given the following code:
https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=242a6ff23679df5d4ac2f718e0ce8415
The current output is:
Ideally the output should look like:
During my journey learning Rust, I've made this mistake a number of types, and pretty much 90% of the time the compiler error was misleading because my actual intention was an
impl Trait
in that position. Suggestingdyn Trait
in this situation leads to confusion and, if an unwitting programmer accepts it, another error immediately following it.I think
rustc
should suggestimpl Trait
beforedyn Trait
in the argument and return type positions. Suggestingdyn Trait
in type argument positions such asBox<Trait>
and in non-function contexts would still make sense.The text was updated successfully, but these errors were encountered: