diff options
Diffstat (limited to 'crates/parser/src/grammar')
-rw-r--r-- | crates/parser/src/grammar/expressions.rs | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/crates/parser/src/grammar/expressions.rs b/crates/parser/src/grammar/expressions.rs index 5f885edfd..0d9dc9348 100644 --- a/crates/parser/src/grammar/expressions.rs +++ b/crates/parser/src/grammar/expressions.rs | |||
@@ -54,7 +54,7 @@ fn is_expr_stmt_attr_allowed(kind: SyntaxKind) -> bool { | |||
54 | !forbid | 54 | !forbid |
55 | } | 55 | } |
56 | 56 | ||
57 | pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) { | 57 | pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi, prefer_expr: bool) { |
58 | let m = p.start(); | 58 | let m = p.start(); |
59 | // test attr_on_expr_stmt | 59 | // test attr_on_expr_stmt |
60 | // fn foo() { | 60 | // fn foo() { |
@@ -90,7 +90,7 @@ pub(super) fn stmt(p: &mut Parser, with_semi: StmtWithSemi) { | |||
90 | p.error(format!("attributes are not allowed on {:?}", kind)); | 90 | p.error(format!("attributes are not allowed on {:?}", kind)); |
91 | } | 91 | } |
92 | 92 | ||
93 | if p.at(T!['}']) { | 93 | if p.at(T!['}']) || (prefer_expr && p.at(EOF)) { |
94 | // test attr_on_last_expr_in_block | 94 | // test attr_on_last_expr_in_block |
95 | // fn foo() { | 95 | // fn foo() { |
96 | // { #[A] bar!()? } | 96 | // { #[A] bar!()? } |
@@ -198,7 +198,7 @@ pub(super) fn expr_block_contents(p: &mut Parser) { | |||
198 | continue; | 198 | continue; |
199 | } | 199 | } |
200 | 200 | ||
201 | stmt(p, StmtWithSemi::Yes) | 201 | stmt(p, StmtWithSemi::Yes, false) |
202 | } | 202 | } |
203 | } | 203 | } |
204 | 204 | ||