@@ -1236,7 +1236,7 @@ impl<'a> Parser<'a> {
1236
1236
Ok ( ( class_name, ItemKind :: Union ( vdata, generics) ) )
1237
1237
}
1238
1238
1239
- fn parse_record_struct_body (
1239
+ pub ( super ) fn parse_record_struct_body (
1240
1240
& mut self ,
1241
1241
adt_ty : & str ,
1242
1242
) -> PResult < ' a , ( Vec < FieldDef > , /* recovered */ bool ) > {
@@ -1470,19 +1470,25 @@ impl<'a> Parser<'a> {
1470
1470
fn parse_field_ident ( & mut self , adt_ty : & str , lo : Span ) -> PResult < ' a , Ident > {
1471
1471
let ( ident, is_raw) = self . ident_or_err ( ) ?;
1472
1472
if !is_raw && ident. is_reserved ( ) {
1473
- let err = if self . check_fn_front_matter ( false ) {
1474
- let _ = self . parse_fn ( & mut Vec :: new ( ) , |_| true , lo) ;
1475
- let mut err = self . struct_span_err (
1476
- lo. to ( self . prev_token . span ) ,
1477
- & format ! ( "functions are not allowed in {} definitions" , adt_ty) ,
1478
- ) ;
1479
- err. help ( "unlike in C++, Java, and C#, functions are declared in `impl` blocks" ) ;
1480
- err. help ( "see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information" ) ;
1481
- err
1473
+ if ident. name == kw:: Underscore {
1474
+ self . sess . gated_spans . gate ( sym:: unnamed_fields, lo) ;
1482
1475
} else {
1483
- self . expected_ident_found ( )
1484
- } ;
1485
- return Err ( err) ;
1476
+ let err = if self . check_fn_front_matter ( false ) {
1477
+ let _ = self . parse_fn ( & mut Vec :: new ( ) , |_| true , lo) ;
1478
+ let mut err = self . struct_span_err (
1479
+ lo. to ( self . prev_token . span ) ,
1480
+ & format ! ( "functions are not allowed in {} definitions" , adt_ty) ,
1481
+ ) ;
1482
+ err. help (
1483
+ "unlike in C++, Java, and C#, functions are declared in `impl` blocks" ,
1484
+ ) ;
1485
+ err. help ( "see https://doc.rust-lang.org/book/ch05-03-method-syntax.html for more information" ) ;
1486
+ err
1487
+ } else {
1488
+ self . expected_ident_found ( )
1489
+ } ;
1490
+ return Err ( err) ;
1491
+ }
1486
1492
}
1487
1493
self . bump ( ) ;
1488
1494
Ok ( ident)
0 commit comments