File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change @@ -1727,9 +1727,10 @@ impl<'a> Parser<'a> {
17271727 /// Checks if current token is one of tokens which cannot be nested like `kw::Enum`. In case
17281728 /// it is, we try to parse the item and report error about nested types.
17291729 fn recover_nested_adt_item ( & mut self , keyword : Symbol ) -> PResult < ' a , bool > {
1730- if self . token . is_keyword ( kw:: Enum ) ||
1730+ if ( self . token . is_keyword ( kw:: Enum ) ||
17311731 self . token . is_keyword ( kw:: Struct ) ||
1732- self . token . is_keyword ( kw:: Union )
1732+ self . token . is_keyword ( kw:: Union ) )
1733+ && self . look_ahead ( 1 , |t| t. is_ident ( ) )
17331734 {
17341735 let kw_token = self . token . clone ( ) ;
17351736 let kw_str = pprust:: token_to_string ( & kw_token) ;
Original file line number Diff line number Diff line change 1+ // This test checks that the union keyword
2+ // is accepted as the name of an enum variant
3+ // when not followed by an identifier
4+ // This special case exists because `union` is a contextual keyword.
5+
6+ #![ allow( warnings) ]
7+
8+ // check-pass
9+
10+ enum A { union }
11+ enum B { union { } }
12+ enum C { union( ) }
13+ fn main ( ) { }
You can’t perform that action at this time.
0 commit comments