File tree Expand file tree Collapse file tree 1 file changed +19
-9
lines changed
compiler/rustc_parse/src/parser Expand file tree Collapse file tree 1 file changed +19
-9
lines changed Original file line number Diff line number Diff line change @@ -1274,18 +1274,28 @@ impl<'a> Parser<'a> {
12741274 ( thin_vec ! [ ] , false )
12751275 } else {
12761276 self . parse_delim_comma_seq ( Delimiter :: Brace , |p| p. parse_enum_variant ( ) ) . map_err (
1277- |mut e | {
1278- e . span_label ( id. span , "while parsing this enum" ) ;
1277+ |mut err | {
1278+ err . span_label ( id. span , "while parsing this enum" ) ;
12791279 if self . token == token:: Colon {
1280- e. span_suggestion_verbose (
1281- prev_span,
1282- "perhaps you meant to use `struct` here" ,
1283- "struct" . to_string ( ) ,
1284- Applicability :: MaybeIncorrect ,
1285- ) ;
1280+ let snapshot = self . create_snapshot_for_diagnostic ( ) ;
1281+ self . bump ( ) ;
1282+ match self . parse_ty ( ) {
1283+ Ok ( _) => {
1284+ err. span_suggestion_verbose (
1285+ prev_span,
1286+ "perhaps you meant to use `struct` here" ,
1287+ "struct" . to_string ( ) ,
1288+ Applicability :: MaybeIncorrect ,
1289+ ) ;
1290+ }
1291+ Err ( e) => {
1292+ e. cancel ( ) ;
1293+ }
1294+ }
1295+ self . restore_snapshot ( snapshot) ;
12861296 }
12871297 self . recover_stmt ( ) ;
1288- e
1298+ err
12891299 } ,
12901300 ) ?
12911301 } ;
You can’t perform that action at this time.
0 commit comments