diff --git a/crates/parser/src/grammar.rs b/crates/parser/src/grammar.rs index 42426a1df2..234e584eeb 100644 --- a/crates/parser/src/grammar.rs +++ b/crates/parser/src/grammar.rs @@ -59,7 +59,7 @@ pub(crate) mod entry { } pub(crate) fn stmt(p: &mut Parser) { - expressions::stmt(p, expressions::StmtWithSemi::No, true); + expressions::stmt(p, expressions::StmtWithSemi::No); } pub(crate) fn pat(p: &mut Parser) { @@ -103,7 +103,7 @@ pub(crate) mod entry { continue; } - expressions::stmt(p, expressions::StmtWithSemi::Optional, true); + expressions::stmt(p, expressions::StmtWithSemi::Optional); } m.complete(p, MACRO_STMTS); diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index 64057a4a67..3238b6e9f4 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs @@ -5,6 +5,7 @@ use super::*; pub(crate) use self::atom::{block_expr, match_arm_list}; pub(super) use self::atom::{literal, LITERAL_FIRST}; +#[derive(PartialEq, Eq)] pub(super) enum StmtWithSemi { Yes, No, @@ -28,7 +29,7 @@ fn expr_no_struct(p: &mut Parser) { expr_bp(p, None, r, 1); } -pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi, prefer_expr: bool) { +pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) { let m = p.start(); // test attr_on_expr_stmt // fn foo() { @@ -52,7 +53,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi, prefer_expr: bool) { }; if let Some((cm, blocklike)) = expr_stmt(p, Some(m)) { - if !(p.at(T!['}']) || (prefer_expr && p.at(EOF))) { + if !(p.at(T!['}']) || (with_semi != StmtWithSemi::Yes && p.at(EOF))) { // test no_semi_after_block // fn foo() { // if true {} @@ -149,7 +150,7 @@ pub(super) fn expr_block_contents(p: &mut Parser) { continue; } - stmt(p, StmtWithSemi::Yes, false); + stmt(p, StmtWithSemi::Yes); } }