@@ -832,16 +832,20 @@ impl<'a> Parser<'a> {
832
832
}
833
833
834
834
fn parse_rename ( & mut self ) -> PResult < ' a , Option < Ident > > {
835
- if self . eat_keyword ( kw:: As ) { self . parse_ident_or_underscore ( ) . map ( Some ) } else { Ok ( None ) }
835
+ if self . eat_keyword ( kw:: As ) {
836
+ self . parse_ident_or_underscore ( true ) . map ( Some )
837
+ } else {
838
+ Ok ( None )
839
+ }
836
840
}
837
841
838
- fn parse_ident_or_underscore ( & mut self ) -> PResult < ' a , Ident > {
842
+ fn parse_ident_or_underscore ( & mut self , recover : bool ) -> PResult < ' a , Ident > {
839
843
match self . token . ident ( ) {
840
844
Some ( ( ident @ Ident { name : kw:: Underscore , .. } , false ) ) => {
841
845
self . bump ( ) ;
842
846
Ok ( ident)
843
847
}
844
- _ => self . parse_ident ( ) ,
848
+ _ => self . parse_ident_common ( recover ) ,
845
849
}
846
850
}
847
851
@@ -1056,7 +1060,8 @@ impl<'a> Parser<'a> {
1056
1060
& mut self ,
1057
1061
m : Option < Mutability > ,
1058
1062
) -> PResult < ' a , ( Ident , P < Ty > , Option < P < ast:: Expr > > ) > {
1059
- let id = if m. is_none ( ) { self . parse_ident_or_underscore ( ) } else { self . parse_ident ( ) } ?;
1063
+ let id =
1064
+ if m. is_none ( ) { self . parse_ident_or_underscore ( true ) } else { self . parse_ident ( ) } ?;
1060
1065
1061
1066
// Parse the type of a `const` or `static mut?` item.
1062
1067
// That is, the `":" $ty` fragment.
@@ -1470,7 +1475,7 @@ impl<'a> Parser<'a> {
1470
1475
vis : Visibility ,
1471
1476
attrs : Vec < Attribute > ,
1472
1477
) -> PResult < ' a , FieldDef > {
1473
- let name = self . parse_ident_or_underscore ( ) ?;
1478
+ let name = self . parse_ident_or_underscore ( false ) ?;
1474
1479
self . expect ( & token:: Colon ) ?;
1475
1480
if name. name == kw:: Underscore {
1476
1481
self . parse_unnamed_field_type ( lo, vis, attrs)
0 commit comments