From fa43ef30f4f96fc8e4ea1f9c4492bcb07b3335ca Mon Sep 17 00:00:00 2001 From: Marcus Klaas de Vries Date: Sat, 19 Jan 2019 01:02:38 +0100 Subject: Change parsing of struct field patterns --- crates/ra_syntax/src/grammar/patterns.rs | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'crates/ra_syntax/src/grammar') diff --git a/crates/ra_syntax/src/grammar/patterns.rs b/crates/ra_syntax/src/grammar/patterns.rs index ff9d94f8a..1ac5efdf6 100644 --- a/crates/ra_syntax/src/grammar/patterns.rs +++ b/crates/ra_syntax/src/grammar/patterns.rs @@ -128,7 +128,11 @@ fn field_pat_list(p: &mut Parser) { while !p.at(EOF) && !p.at(R_CURLY) { match p.current() { DOTDOT => p.bump(), - _ => field_pat(p), + IDENT if p.nth(1) == COLON => field_pat(p), + L_CURLY => error_block(p, "expected ident"), + _ => { + bind_pat(p, false); + } } if !p.at(R_CURLY) { p.expect(COMMA); @@ -139,18 +143,13 @@ fn field_pat_list(p: &mut Parser) { } fn field_pat(p: &mut Parser) { + assert!(p.at(IDENT)); + assert!(p.nth(1) == COLON); + let m = p.start(); - match p.current() { - IDENT if p.nth(1) == COLON => { - name(p); - p.bump(); - pattern(p); - } - L_CURLY => error_block(p, "expected ident"), - _ => { - bind_pat(p, false); - } - } + name(p); + p.bump(); + pattern(p); m.complete(p, FIELD_PAT); } -- cgit v1.2.3