aboutsummaryrefslogtreecommitdiff
path: root/crates/libsyntax2/src/grammar
diff options
context:
space:
mode:
authorAleksey Kladov <[email protected]>2018-09-08 08:55:09 +0100
committerAleksey Kladov <[email protected]>2018-09-08 08:55:09 +0100
commitf48b9d9be737339be988042ca88d31330738618c (patch)
tree5d509fa71a1bb5286faa8b3691d4d757e5b5c8c6 /crates/libsyntax2/src/grammar
parent749907d330e5487eb7997479e2aba4ac2c2e3494 (diff)
Fix block structure in enums
Diffstat (limited to 'crates/libsyntax2/src/grammar')
-rw-r--r--crates/libsyntax2/src/grammar/items/mod.rs8
-rw-r--r--crates/libsyntax2/src/grammar/items/nominal.rs (renamed from crates/libsyntax2/src/grammar/items/structs.rs)13
2 files changed, 15 insertions, 6 deletions
diff --git a/crates/libsyntax2/src/grammar/items/mod.rs b/crates/libsyntax2/src/grammar/items/mod.rs
index 57742ecb9..85d7fe770 100644
--- a/crates/libsyntax2/src/grammar/items/mod.rs
+++ b/crates/libsyntax2/src/grammar/items/mod.rs
@@ -1,11 +1,11 @@
1 1
2mod consts; 2mod consts;
3mod structs; 3mod nominal;
4mod traits; 4mod traits;
5mod use_item; 5mod use_item;
6 6
7use super::*; 7use super::*;
8pub(crate) use self::structs::named_field_def_list; 8pub(crate) use self::nominal::named_field_def_list;
9 9
10// test mod_contents 10// test mod_contents
11// fn foo() {} 11// fn foo() {}
@@ -176,7 +176,7 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
176 MODULE 176 MODULE
177 } 177 }
178 STRUCT_KW => { 178 STRUCT_KW => {
179 structs::struct_def(p); 179 nominal::struct_def(p);
180 if p.at(SEMI) { 180 if p.at(SEMI) {
181 p.err_and_bump( 181 p.err_and_bump(
182 "expected item, found `;`\n\ 182 "expected item, found `;`\n\
@@ -186,7 +186,7 @@ fn items_without_modifiers(p: &mut Parser) -> Option<SyntaxKind> {
186 STRUCT_DEF 186 STRUCT_DEF
187 } 187 }
188 ENUM_KW => { 188 ENUM_KW => {
189 structs::enum_def(p); 189 nominal::enum_def(p);
190 ENUM_DEF 190 ENUM_DEF
191 } 191 }
192 USE_KW => { 192 USE_KW => {
diff --git a/crates/libsyntax2/src/grammar/items/structs.rs b/crates/libsyntax2/src/grammar/items/nominal.rs
index f1e78865c..3db5b24af 100644
--- a/crates/libsyntax2/src/grammar/items/structs.rs
+++ b/crates/libsyntax2/src/grammar/items/nominal.rs
@@ -91,6 +91,10 @@ pub(crate) fn named_field_def_list(p: &mut Parser) {
91 let m = p.start(); 91 let m = p.start();
92 p.bump(); 92 p.bump();
93 while !p.at(R_CURLY) && !p.at(EOF) { 93 while !p.at(R_CURLY) && !p.at(EOF) {
94 if p.at(L_CURLY) {
95 error_block(p, "expected field");
96 continue;
97 }
94 named_field_def(p); 98 named_field_def(p);
95 if !p.at(R_CURLY) { 99 if !p.at(R_CURLY) {
96 p.expect(COMMA); 100 p.expect(COMMA);
@@ -127,10 +131,15 @@ fn pos_field_list(p: &mut Parser) {
127 return; 131 return;
128 } 132 }
129 while !p.at(R_PAREN) && !p.at(EOF) { 133 while !p.at(R_PAREN) && !p.at(EOF) {
130 let pos_field = p.start(); 134 let m = p.start();
131 opt_visibility(p); 135 opt_visibility(p);
136 if !p.at_ts(types::TYPE_FIRST) {
137 p.error("expected a type");
138 m.complete(p, ERROR);
139 break;
140 }
132 types::type_(p); 141 types::type_(p);
133 pos_field.complete(p, POS_FIELD); 142 m.complete(p, POS_FIELD);
134 143
135 if !p.at(R_PAREN) { 144 if !p.at(R_PAREN) {
136 p.expect(COMMA); 145 p.expect(COMMA);