about summary refs log tree commit diff
path: root/compiler/rustc_parse/src/parser/expr.rs
diff options
context:
space:
mode:
authorDavid Tolnay <dtolnay@gmail.com>2023-12-29 16:30:34 -0800
committerDavid Tolnay <dtolnay@gmail.com>2024-05-11 15:48:59 -0700
commit9e1cf2098d68356bccf7112bbff1d9b565e80a02 (patch)
treef9b2fa5f5790e5421fa215a2ade0c568052306e8 /compiler/rustc_parse/src/parser/expr.rs
parentcbb8714a3f8a04cce698719df338fb095c40f479 (diff)
downloadrust-9e1cf2098d68356bccf7112bbff1d9b565e80a02.tar.gz
rust-9e1cf2098d68356bccf7112bbff1d9b565e80a02.zip
Macro call with braces does not require semicolon to be statement
This commit by itself is supposed to have no effect on behavior. All of
the call sites are updated to preserve their previous behavior.

The behavior changes are in the commits that follow.
Diffstat (limited to 'compiler/rustc_parse/src/parser/expr.rs')
-rw-r--r--compiler/rustc_parse/src/parser/expr.rs16
1 files changed, 12 insertions, 4 deletions
diff --git a/compiler/rustc_parse/src/parser/expr.rs b/compiler/rustc_parse/src/parser/expr.rs
index 951c3495995..5f7bd0835d3 100644
--- a/compiler/rustc_parse/src/parser/expr.rs
+++ b/compiler/rustc_parse/src/parser/expr.rs
@@ -498,7 +498,10 @@ impl<'a> Parser<'a> {
     /// Checks if this expression is a successfully parsed statement.
     fn expr_is_complete(&self, e: &Expr) -> bool {
         self.restrictions.contains(Restrictions::STMT_EXPR)
-            && !classify::expr_requires_semi_to_be_stmt_FIXME(e)
+            && match e.kind {
+                ExprKind::MacCall(_) => false,
+                _ => !classify::expr_requires_semi_to_be_stmt(e),
+            }
     }
 
     /// Parses `x..y`, `x..=y`, and `x..`/`x..=`.
@@ -2694,7 +2697,10 @@ impl<'a> Parser<'a> {
                 // If it's not a free-standing expression, and is followed by a block,
                 // then it's very likely the condition to an `else if`.
                     if self.check(&TokenKind::OpenDelim(Delimiter::Brace))
-                        && classify::expr_requires_semi_to_be_stmt_FIXME(&cond) =>
+                        && match cond.kind {
+                            ExprKind::MacCall(_) => true,
+                            _ => classify::expr_requires_semi_to_be_stmt(&cond),
+                        } =>
                 {
                     self.dcx().emit_err(errors::ExpectedElseBlock {
                         first_tok_span,
@@ -3136,8 +3142,10 @@ impl<'a> Parser<'a> {
                         err
                     })?;
 
-                let require_comma = classify::expr_requires_semi_to_be_stmt_FIXME(&expr)
-                    && this.token != token::CloseDelim(Delimiter::Brace);
+                let require_comma = match expr.kind {
+                    ExprKind::MacCall(_) => true,
+                    _ => classify::expr_requires_semi_to_be_stmt(&expr),
+                } && this.token != token::CloseDelim(Delimiter::Brace);
 
                 if !require_comma {
                     arm_body = Some(expr);