From f04cff102f2748f8b51e25cf1c28a6097fee1592 Mon Sep 17 00:00:00 2001 From: Lukas Wirth Date: Fri, 30 Jul 2021 13:12:52 +0200 Subject: [PATCH] Simplify --- crates/parser/src/grammar/expressions/atom.rs | 6 ++---- .../test_data/parser/err/0032_match_arms_inner_attrs.rast | 4 ++-- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/crates/parser/src/grammar/expressions/atom.rs b/crates/parser/src/grammar/expressions/atom.rs index 8e7dbea3e7..70037c02d4 100644 --- a/crates/parser/src/grammar/expressions/atom.rs +++ b/crates/parser/src/grammar/expressions/atom.rs @@ -448,10 +448,8 @@ fn match_arm(p: &mut Parser) { // _ => () // } // } - if blocklike.is_block() { - p.eat(T![,]); - } else if !p.at(T!['}']) { - p.expect(T![,]); + if !p.eat(T![,]) && !blocklike.is_block() && !p.at(T!['}']) { + p.error("expected `,`"); } m.complete(p, MATCH_ARM); } diff --git a/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast b/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast index 83b9e79c3a..9524f5ccc7 100644 --- a/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast +++ b/crates/syntax/test_data/parser/err/0032_match_arms_inner_attrs.rast @@ -194,11 +194,11 @@ SOURCE_FILE@0..293 error 52..52: expected `[` error 52..52: expected pattern error 53..53: expected FAT_ARROW -error 78..78: expected COMMA +error 78..78: expected `,` error 161..161: expected `[` error 161..161: expected pattern error 162..162: expected FAT_ARROW error 232..232: expected `[` error 232..232: expected pattern error 233..233: expected FAT_ARROW -error 250..250: expected COMMA +error 250..250: expected `,`