File tree Expand file tree Collapse file tree 2 files changed +25
-3
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 2 files changed +25
-3
lines changed Original file line number Diff line number Diff line change @@ -1788,7 +1788,23 @@ impl<'a> Parser<'a> {
17881788 }
17891789 }
17901790 } else {
1791- self . expected_ident_found ( )
1791+ let mut err = self . expected_ident_found ( ) ;
1792+ if let Some ( ( ident, _) ) = self . token . ident ( ) && ident. as_str ( ) == "let" {
1793+ self . bump ( ) ; // `let`
1794+ let span = self . prev_token . span . until ( self . token . span ) ;
1795+ err. span_suggestion (
1796+ span,
1797+ "remove the let, the `let` keyword is not allowed in struct field definitions" ,
1798+ String :: new ( ) ,
1799+ Applicability :: MachineApplicable ,
1800+ ) ;
1801+ err. note ( "the `let` keyword is not allowed in `struct` fields" ) ;
1802+ err. note ( "see <https://doc.rust-lang.org/book/ch05-01-defining-structs.html> for more information" ) ;
1803+ err. emit ( ) ;
1804+ self . bump ( ) ;
1805+ return Ok ( ident) ;
1806+ }
1807+ err
17921808 } ;
17931809 return Err ( err) ;
17941810 }
Original file line number Diff line number Diff line change 11error: expected identifier, found keyword `let`
22 --> $DIR/removed-syntax-field-let.rs:2:5
33 |
4- LL | struct S {
5- | - while parsing this struct
64LL | let foo: (),
75 | ^^^ expected identifier, found keyword
6+ |
7+ = note: the `let` keyword is not allowed in `struct` fields
8+ = note: see <https://doc.rust-lang.org/book/ch05-01-defining-structs.html> for more information
9+ help: remove the let, the `let` keyword is not allowed in struct field definitions
10+ |
11+ LL - let foo: (),
12+ LL + foo: (),
13+ |
814
915error: aborting due to previous error
1016
You can’t perform that action at this time.
0 commit comments