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