@@ -832,16 +832,20 @@ impl<'a> Parser<'a> {
832832 }
833833
834834 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+ }
836840 }
837841
838- fn parse_ident_or_underscore ( & mut self ) -> PResult < ' a , Ident > {
842+ fn parse_ident_or_underscore ( & mut self , recover : bool ) -> PResult < ' a , Ident > {
839843 match self . token . ident ( ) {
840844 Some ( ( ident @ Ident { name : kw:: Underscore , .. } , false ) ) => {
841845 self . bump ( ) ;
842846 Ok ( ident)
843847 }
844- _ => self . parse_ident ( ) ,
848+ _ => self . parse_ident_common ( recover ) ,
845849 }
846850 }
847851
@@ -1056,7 +1060,8 @@ impl<'a> Parser<'a> {
10561060 & mut self ,
10571061 m : Option < Mutability > ,
10581062 ) -> 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 ( ) } ?;
10601065
10611066 // Parse the type of a `const` or `static mut?` item.
10621067 // That is, the `":" $ty` fragment.
@@ -1470,7 +1475,7 @@ impl<'a> Parser<'a> {
14701475 vis : Visibility ,
14711476 attrs : Vec < Attribute > ,
14721477 ) -> PResult < ' a , FieldDef > {
1473- let name = self . parse_ident_or_underscore ( ) ?;
1478+ let name = self . parse_ident_or_underscore ( false ) ?;
14741479 self . expect ( & token:: Colon ) ?;
14751480 if name. name == kw:: Underscore {
14761481 self . parse_unnamed_field_type ( lo, vis, attrs)
0 commit comments