1
1
use super :: diagnostics:: { dummy_arg, ConsumeClosingDelim } ;
2
- use super :: ty:: { AllowAnonStructOrUnion , AllowPlus , RecoverQPath , RecoverReturnSign } ;
2
+ use super :: ty:: { AllowPlus , RecoverQPath , RecoverReturnSign } ;
3
3
use super :: { AttrWrapper , FollowedByType , ForceCollect , Parser , PathStyle , TrailingToken } ;
4
4
use crate :: errors:: { self , MacroExpandsToAdtField } ;
5
5
use crate :: fluent_generated as fluent;
@@ -590,7 +590,7 @@ impl<'a> Parser<'a> {
590
590
self . bump ( ) ; // `..`, do not add it to expected tokens
591
591
Some ( self . mk_ty ( self . prev_token . span , TyKind :: Err ) )
592
592
} else if has_for || self . token . can_begin_type ( ) {
593
- Some ( self . parse_second_ty_for_item_impl ( ) ?)
593
+ Some ( self . parse_ty ( ) ?)
594
594
} else {
595
595
None
596
596
} ;
@@ -1595,26 +1595,11 @@ impl<'a> Parser<'a> {
1595
1595
Ok ( ( class_name, ItemKind :: Union ( vdata, generics) ) )
1596
1596
}
1597
1597
1598
- fn parse_record_struct_body (
1598
+ pub ( crate ) fn parse_record_struct_body (
1599
1599
& mut self ,
1600
1600
adt_ty : & str ,
1601
1601
ident_span : Span ,
1602
1602
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 > ,
1618
1603
) -> PResult < ' a , ( ThinVec < FieldDef > , /* recovered */ bool ) > {
1619
1604
let mut fields = ThinVec :: new ( ) ;
1620
1605
let mut recovered = false ;
@@ -1628,18 +1613,6 @@ impl<'a> Parser<'a> {
1628
1613
match field {
1629
1614
Ok ( field) => fields. push ( field) ,
1630
1615
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
- }
1643
1616
err. span_label ( ident_span, format ! ( "while parsing this {adt_ty}" ) ) ;
1644
1617
err. emit ( ) ;
1645
1618
break ;
0 commit comments