diff options
Diffstat (limited to 'crates/ra_parser')
-rw-r--r-- | crates/ra_parser/src/grammar/expressions/atom.rs | 1 | ||||
-rw-r--r-- | crates/ra_parser/src/grammar/patterns.rs | 15 |
2 files changed, 13 insertions, 3 deletions
diff --git a/crates/ra_parser/src/grammar/expressions/atom.rs b/crates/ra_parser/src/grammar/expressions/atom.rs index 6c7fdc2cd..457f42a26 100644 --- a/crates/ra_parser/src/grammar/expressions/atom.rs +++ b/crates/ra_parser/src/grammar/expressions/atom.rs | |||
@@ -54,6 +54,7 @@ pub(super) const ATOM_EXPR_FIRST: TokenSet = | |||
54 | LIFETIME, | 54 | LIFETIME, |
55 | ASYNC_KW, | 55 | ASYNC_KW, |
56 | TRY_KW, | 56 | TRY_KW, |
57 | LOOP_KW | ||
57 | ]); | 58 | ]); |
58 | 59 | ||
59 | const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; | 60 | const EXPR_RECOVERY_SET: TokenSet = token_set![LET_KW]; |
diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs index a4ffd6960..aa9a6d18e 100644 --- a/crates/ra_parser/src/grammar/patterns.rs +++ b/crates/ra_parser/src/grammar/patterns.rs | |||
@@ -167,7 +167,7 @@ fn record_field_pat_list(p: &mut Parser) { | |||
167 | // A trailing `..` is *not* treated as a DOT_DOT_PAT. | 167 | // A trailing `..` is *not* treated as a DOT_DOT_PAT. |
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 | INT_NUMBER if p.nth(1) == T![:] => record_field_pat(p), |
171 | T!['{'] => error_block(p, "expected ident"), | 171 | T!['{'] => error_block(p, "expected ident"), |
172 | T![box] => { | 172 | T![box] => { |
173 | box_pat(p); | 173 | box_pat(p); |
@@ -184,12 +184,21 @@ fn record_field_pat_list(p: &mut Parser) { | |||
184 | m.complete(p, RECORD_FIELD_PAT_LIST); | 184 | m.complete(p, RECORD_FIELD_PAT_LIST); |
185 | } | 185 | } |
186 | 186 | ||
187 | // test record_field_pat | ||
188 | // fn foo() { | ||
189 | // let S { 0: 1 } = (); | ||
190 | // let S { x: 1 } = (); | ||
191 | // } | ||
187 | fn record_field_pat(p: &mut Parser) { | 192 | fn record_field_pat(p: &mut Parser) { |
188 | assert!(p.at(IDENT)); | 193 | assert!(p.at(IDENT) || p.at(INT_NUMBER)); |
189 | assert!(p.nth(1) == T![:]); | 194 | assert!(p.nth(1) == T![:]); |
190 | 195 | ||
191 | let m = p.start(); | 196 | let m = p.start(); |
192 | name(p); | 197 | |
198 | if !p.eat(INT_NUMBER) { | ||
199 | name(p) | ||
200 | } | ||
201 | |||
193 | p.bump_any(); | 202 | p.bump_any(); |
194 | pattern(p); | 203 | pattern(p); |
195 | m.complete(p, RECORD_FIELD_PAT); | 204 | m.complete(p, RECORD_FIELD_PAT); |