diff options
Diffstat (limited to 'crates/libsyntax2/src/grammar/items/nominal.rs')
-rw-r--r-- | crates/libsyntax2/src/grammar/items/nominal.rs | 16 |
1 files changed, 10 insertions, 6 deletions
diff --git a/crates/libsyntax2/src/grammar/items/nominal.rs b/crates/libsyntax2/src/grammar/items/nominal.rs index 11c43e371..8d02ad555 100644 --- a/crates/libsyntax2/src/grammar/items/nominal.rs +++ b/crates/libsyntax2/src/grammar/items/nominal.rs | |||
@@ -1,8 +1,8 @@ | |||
1 | use super::*; | 1 | use super::*; |
2 | 2 | ||
3 | pub(super) fn struct_def(p: &mut Parser) { | 3 | pub(super) fn struct_def(p: &mut Parser, kind: SyntaxKind) { |
4 | assert!(p.at(STRUCT_KW)); | 4 | assert!(p.at(STRUCT_KW) || p.at_contextual_kw("union")); |
5 | p.bump(); | 5 | p.bump_remap(kind); |
6 | 6 | ||
7 | name_r(p, ITEM_RECOVERY_SET); | 7 | name_r(p, ITEM_RECOVERY_SET); |
8 | type_params::opt_type_param_list(p); | 8 | type_params::opt_type_param_list(p); |
@@ -22,19 +22,23 @@ pub(super) fn struct_def(p: &mut Parser) { | |||
22 | } | 22 | } |
23 | } | 23 | } |
24 | } | 24 | } |
25 | SEMI => { | 25 | SEMI if kind == STRUCT_KW => { |
26 | p.bump(); | 26 | p.bump(); |
27 | return; | 27 | return; |
28 | } | 28 | } |
29 | L_CURLY => named_field_def_list(p), | 29 | L_CURLY => named_field_def_list(p), |
30 | L_PAREN => { | 30 | L_PAREN if kind == STRUCT_KW => { |
31 | pos_field_list(p); | 31 | pos_field_list(p); |
32 | p.expect(SEMI); | 32 | p.expect(SEMI); |
33 | } | 33 | } |
34 | _ => { | 34 | _ if kind == STRUCT_KW => { |
35 | p.error("expected `;`, `{`, or `(`"); | 35 | p.error("expected `;`, `{`, or `(`"); |
36 | return; | 36 | return; |
37 | } | 37 | } |
38 | _ => { | ||
39 | p.error("expected `{`"); | ||
40 | return; | ||
41 | } | ||
38 | } | 42 | } |
39 | } | 43 | } |
40 | 44 | ||