aboutsummaryrefslogtreecommitdiff
path: root/crates/ra_parser/src
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2019-09-20 16:54:01 +0100
committerGitHub <[email protected]>2019-09-20 16:54:01 +0100
commit3575f7c4a2c20ed84626e2652be195fc26dd1add (patch)
tree2610083075f1a4d7f3f19a3a31d15991c61f873f /crates/ra_parser/src
parent0492b18ed47115c630cf3490fcdf904155f6e496 (diff)
parent17a45a686c42522ffb668b1989d58219f76caf51 (diff)
Merge #1884
1884: Add indexing to record_field_pat r=matklad a=kjeremy Fixes #1870 Co-authored-by: kjeremy <[email protected]>
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);