11use super :: diagnostics:: { dummy_arg, ConsumeClosingDelim } ;
2- use super :: ty:: { AllowAnonStructOrUnion , AllowPlus , RecoverQPath , RecoverReturnSign } ;
2+ use super :: ty:: { AllowPlus , RecoverQPath , RecoverReturnSign } ;
33use super :: { AttrWrapper , FollowedByType , ForceCollect , Parser , PathStyle , TrailingToken } ;
44use crate :: errors:: { self , MacroExpandsToAdtField } ;
55use crate :: fluent_generated as fluent;
@@ -590,7 +590,7 @@ impl<'a> Parser<'a> {
590590 self . bump ( ) ; // `..`, do not add it to expected tokens
591591 Some ( self . mk_ty ( self . prev_token . span , TyKind :: Err ) )
592592 } else if has_for || self . token . can_begin_type ( ) {
593- Some ( self . parse_second_ty_for_item_impl ( ) ?)
593+ Some ( self . parse_ty ( ) ?)
594594 } else {
595595 None
596596 } ;
@@ -1595,26 +1595,11 @@ impl<'a> Parser<'a> {
15951595 Ok ( ( class_name, ItemKind :: Union ( vdata, generics) ) )
15961596 }
15971597
1598- fn parse_record_struct_body (
1598+ pub ( crate ) fn parse_record_struct_body (
15991599 & mut self ,
16001600 adt_ty : & str ,
16011601 ident_span : Span ,
16021602 parsed_where : bool ,
1603- ) -> PResult < ' a , ( ThinVec < FieldDef > , /* recovered */ bool ) > {
1604- self . parse_record_struct_body_common (
1605- adt_ty,
1606- ident_span,
1607- parsed_where,
1608- AllowAnonStructOrUnion :: Yes ,
1609- )
1610- }
1611-
1612- pub ( crate ) fn parse_record_struct_body_common (
1613- & mut self ,
1614- adt_ty : & str ,
1615- ident_span : Span ,
1616- parsed_where : bool ,
1617- allow_anon_struct_or_union : AllowAnonStructOrUnion < ' a > ,
16181603 ) -> PResult < ' a , ( ThinVec < FieldDef > , /* recovered */ bool ) > {
16191604 let mut fields = ThinVec :: new ( ) ;
16201605 let mut recovered = false ;
@@ -1628,18 +1613,6 @@ impl<'a> Parser<'a> {
16281613 match field {
16291614 Ok ( field) => fields. push ( field) ,
16301615 Err ( mut err) => {
1631- // When recovering the anonymous structs or unions, we should't emit the error
1632- // immediately, because it may also be a type path `union` followed by a block,
1633- // such as `impl union { fn foo() {} }`. Here we are actaully not parsing a
1634- // record struct body but an `impl` body.
1635- //
1636- // Instead, the error should be thrown and handled by the caller
1637- // `parse_anon_struct_or_union`.
1638- if let AllowAnonStructOrUnion :: RecoverNonEmptyOrElse ( _) =
1639- allow_anon_struct_or_union
1640- {
1641- return Err ( err) ;
1642- }
16431616 err. span_label ( ident_span, format ! ( "while parsing this {adt_ty}" ) ) ;
16441617 err. emit ( ) ;
16451618 break ;
0 commit comments