9cda9e0ab6
make error emitted on `impl &Trait` nicer Fixes #106694 Turned out to be simpler than I thought, also added UI test. Before: ([playground](https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=9bda53271ef3a8886793cf427b8cea91)) ```text error: expected one of `:`, ``@`,` or `|`, found `)` --> src/main.rs:2:22 | 2 | fn foo(_: impl &Trait) {} | ^ expected one of `:`, ``@`,` or `|` | = note: anonymous parameters are removed in the 2018 edition (see RFC 1685) help: if this is a parameter name, give it a type | 2 | fn foo(_: impl Trait: &TypeName) {} | ~~~~~~~~~~~~~~~~ help: if this is a type, explicitly ignore the parameter name | 2 | fn foo(_: impl _: &Trait) {} | ++ error: expected one of `!`, `(`, `)`, `,`, `?`, `for`, `~`, lifetime, or path, found `&` --> src/main.rs:2:16 | 2 | fn foo(_: impl &Trait) {} | -^ expected one of 9 possible tokens | | | help: missing `,` error: expected one of `!`, `(`, `,`, `=`, `>`, `?`, `for`, `~`, lifetime, or path, found `&` --> src/main.rs:3:11 | 3 | fn bar<T: &Trait>(_: T) {} | ^ expected one of 10 possible tokens ``` After: ```text error: expected a trait, found type --> <anon>:2:16 | 2 | fn foo(_: impl &Trait) {} | -^^^^^ | | | help: consider removing the indirection error: expected a trait, found type --> <anon>:3:11 | 3 | fn bar<T: &Trait>(_: T) {} | -^^^^^ | | | help: consider removing the indirection ``` |
||
---|---|---|
.. | ||
attr_wrapper.rs | ||
attr.rs | ||
diagnostics.rs | ||
expr.rs | ||
generics.rs | ||
item.rs | ||
mod.rs | ||
nonterminal.rs | ||
pat.rs | ||
path.rs | ||
stmt.rs | ||
ty.rs |