aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src/grammar
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src/grammar')
-rw-r--r--crates/ra_parser/src/grammar/patterns.rs15
1 files changed, 13 insertions, 2 deletions
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs
index a4ffd6960..cf722eef4 100644
--- a/crates/ra_parser/src/grammar/patterns.rs
+++ b/crates/ra_parser/src/grammar/patterns.rs
@@ -168,6 +168,7 @@ fn record_field_pat_list(p: &mut Parser) {
168 T![.] if p.at(T![..]) => p.bump(T![..]), 168 T![.] if p.at(T![..]) => p.bump(T![..]),
169 169
170 IDENT if p.nth(1) == T![:] => record_field_pat(p), 170 IDENT if p.nth(1) == T![:] => record_field_pat(p),
171 INT_NUMBER if p.nth(1) == T![:] => record_field_pat(p),
171 T!['{'] => error_block(p, "expected ident"), 172 T!['{'] => error_block(p, "expected ident"),
172 T![box] => { 173 T![box] => {
173 box_pat(p); 174 box_pat(p);
@@ -184,12 +185,22 @@ fn record_field_pat_list(p: &mut Parser) {
184 m.complete(p, RECORD_FIELD_PAT_LIST); 185 m.complete(p, RECORD_FIELD_PAT_LIST);
185} 186}
186 187
188// test record_field_pat
189// fn foo() {
190// let S { 0: 1 } = ();
191// let S { x: 1 } = ();
192// }
187fn record_field_pat(p: &mut Parser) { 193fn record_field_pat(p: &mut Parser) {
188 assert!(p.at(IDENT)); 194 assert!(p.at(IDENT) || p.at(INT_NUMBER));
189 assert!(p.nth(1) == T![:]); 195 assert!(p.nth(1) == T![:]);
190 196
191 let m = p.start(); 197 let m = p.start();
192 name(p); 198
199 match p.current() {
200 IDENT => name(p),
201 _ => p.bump_any(),
202 }
203
193 p.bump_any(); 204 p.bump_any();
194 pattern(p); 205 pattern(p);
195 m.complete(p, RECORD_FIELD_PAT); 206 m.complete(p, RECORD_FIELD_PAT);