@@ -1236,7 +1236,7 @@ impl<'a> Parser<'a> {
12361236 Ok ( ( class_name, ItemKind :: Union ( vdata, generics) ) )
12371237 }
12381238
1239- fn parse_record_struct_body (
1239+ pub ( super ) fn parse_record_struct_body (
12401240 & mut self ,
12411241 adt_ty : & str ,
12421242 ) -> PResult < ' a , ( Vec < FieldDef > , /* recovered */ bool ) > {
@@ -1470,19 +1470,25 @@ impl<'a> Parser<'a> {
14701470 fn parse_field_ident ( & mut self , adt_ty : & str , lo : Span ) -> PResult < ' a , Ident > {
14711471 let ( ident, is_raw) = self . ident_or_err ( ) ?;
14721472 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) ;
14821475 } 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+ }
14861492 }
14871493 self . bump ( ) ;
14881494 Ok ( ident)
0 commit comments