File tree Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Expand file tree Collapse file tree 3 files changed +24
-1
lines changed Original file line number Diff line number Diff line change @@ -6716,8 +6716,16 @@ impl<'a> Parser<'a> {
67166716 ast:: ImplPolarity :: Positive
67176717 } ;
67186718
6719+ let possible_missing_trait = self . look_ahead ( 0 , |t| t. is_keyword ( keywords:: For ) ) ;
6720+
67196721 // Parse both types and traits as a type, then reinterpret if necessary.
6720- let ty_first = self . parse_ty ( ) ?;
6722+ let ty_first = self . parse_ty ( ) . map_err ( |mut err| {
6723+ if possible_missing_trait {
6724+ err. help ( "did you forget a trait name after `impl`?" ) ;
6725+ }
6726+
6727+ err
6728+ } ) ?;
67216729
67226730 // If `for` is missing we try to recover.
67236731 let has_for = self . eat_keyword ( keywords:: For ) ;
Original file line number Diff line number Diff line change 1+ struct T ;
2+
3+ impl for T { }
4+
5+ fn main ( ) { }
Original file line number Diff line number Diff line change 1+ error: expected `<`, found `T`
2+ --> $DIR/issue-56031.rs:3:10
3+ |
4+ LL | impl for T {}
5+ | ^ expected `<` here
6+ |
7+ = help: did you forget a trait name after `impl`?
8+
9+ error: aborting due to previous error
10+
You can’t perform that action at this time.
0 commit comments