From 5a65d4d9fb84c324e8364f4d89adae258d5a1789 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Fri, 20 Sep 2019 11:43:34 -0400 Subject: Add indexing to record_field_pat --- crates/ra_parser/src/grammar/patterns.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'crates/ra_parser/src/grammar') 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) { T![.] if p.at(T![..]) => p.bump(T![..]), IDENT if p.nth(1) == T![:] => record_field_pat(p), + INT_NUMBER if p.nth(1) == T![:] => record_field_pat(p), T!['{'] => error_block(p, "expected ident"), T![box] => { box_pat(p); @@ -184,12 +185,22 @@ fn record_field_pat_list(p: &mut Parser) { m.complete(p, RECORD_FIELD_PAT_LIST); } +// test record_field_pat +// fn foo() { +// let S { 0: 1 } = (); +// let S { x: 1 } = (); +// } fn record_field_pat(p: &mut Parser) { - assert!(p.at(IDENT)); + assert!(p.at(IDENT) || p.at(INT_NUMBER)); assert!(p.nth(1) == T![:]); let m = p.start(); - name(p); + + match p.current() { + IDENT => name(p), + _ => p.bump_any(), + } + p.bump_any(); pattern(p); m.complete(p, RECORD_FIELD_PAT); -- cgit v1.2.3 From 17a45a686c42522ffb668b1989d58219f76caf51 Mon Sep 17 00:00:00 2001 From: kjeremy Date: Fri, 20 Sep 2019 11:49:45 -0400 Subject: Apply suggestion --- crates/ra_parser/src/grammar/patterns.rs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'crates/ra_parser/src/grammar') diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs index cf722eef4..877ae5b7a 100644 --- a/crates/ra_parser/src/grammar/patterns.rs +++ b/crates/ra_parser/src/grammar/patterns.rs @@ -196,9 +196,8 @@ fn record_field_pat(p: &mut Parser) { let m = p.start(); - match p.current() { - IDENT => name(p), - _ => p.bump_any(), + if !p.eat(INT_NUMBER) { + name(p) } p.bump_any(); -- cgit v1.2.3