From 49b53cd7a0861cdba65643e3da441eefbe18d6e6 Mon Sep 17 00:00:00 2001 From: Matthew Jasper Date: Mon, 10 Feb 2020 20:11:44 +0000 Subject: Address review comments --- crates/ra_parser/src/grammar/patterns.rs | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) (limited to 'crates/ra_parser/src') diff --git a/crates/ra_parser/src/grammar/patterns.rs b/crates/ra_parser/src/grammar/patterns.rs index c6a2e4d39..3afbaa82b 100644 --- a/crates/ra_parser/src/grammar/patterns.rs +++ b/crates/ra_parser/src/grammar/patterns.rs @@ -41,16 +41,14 @@ fn pattern_r(p: &mut Parser, recovery_set: TokenSet) { let m = p.start(); pattern_single_r(p, recovery_set); - let mut is_or_pat = false; + if !p.at(T![|]) { + m.abandon(p); + return; + } while p.eat(T![|]) { - is_or_pat = true; pattern_single_r(p, recovery_set); } - if is_or_pat { - m.complete(p, OR_PAT); - } else { - m.abandon(p); - } + m.complete(p, OR_PAT); } fn pattern_single_r(p: &mut Parser, recovery_set: TokenSet) { @@ -292,6 +290,9 @@ fn ref_pat(p: &mut Parser) -> CompletedMarker { // test tuple_pat // fn main() { // let (a, b, ..) = (); +// let (a,) = (); +// let (..) = (); +// let () = (); // } fn tuple_pat(p: &mut Parser) -> CompletedMarker { assert!(p.at(T!['('])); -- cgit v1.2.3