aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src
diff options
context:
space:
mode:
Diffstat (limited to 'crates/ra_parser/src')
-rw-r--r--crates/ra_parser/src/grammar/patterns.rs14
1 files changed, 12 insertions, 2 deletions
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs
index a4ffd6960..877ae5b7a 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,21 @@ 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 if !p.eat(INT_NUMBER) {
200 name(p)
201 }
202
193 p.bump_any(); 203 p.bump_any();
194 pattern(p); 204 pattern(p);
195 m.complete(p, RECORD_FIELD_PAT); 205 m.complete(p, RECORD_FIELD_PAT);