File tree 2 files changed +16
-2
lines changed
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> {
1727
1727
/// Checks if current token is one of tokens which cannot be nested like `kw::Enum`. In case
1728
1728
/// it is, we try to parse the item and report error about nested types.
1729
1729
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 ) ||
1731
1731
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 ( ) )
1733
1734
{
1734
1735
let kw_token = self . token . clone ( ) ;
1735
1736
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