File tree 1 file changed +19
-9
lines changed
compiler/rustc_parse/src/parser
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> {
1274
1274
( thin_vec ! [ ] , false )
1275
1275
} else {
1276
1276
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" ) ;
1279
1279
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) ;
1286
1296
}
1287
1297
self . recover_stmt ( ) ;
1288
- e
1298
+ err
1289
1299
} ,
1290
1300
) ?
1291
1301
} ;
You can’t perform that action at this time.
0 commit comments