about summary refs log tree commit diff
path: root/compiler/rustc_ast/src
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_ast/src
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_ast/src')
-rw-r--r--compiler/rustc_ast/src/util/classify.rs30
1 files changed, 17 insertions, 13 deletions
diff --git a/compiler/rustc_ast/src/util/classify.rs b/compiler/rustc_ast/src/util/classify.rs
index 5ed8d95b12d..86383af1f7c 100644
--- a/compiler/rustc_ast/src/util/classify.rs
+++ b/compiler/rustc_ast/src/util/classify.rs
@@ -42,19 +42,23 @@ use crate::{ast, token::Delimiter};
 ///     _ => m! {} - 1,  // binary subtraction operator
 /// }
 /// ```
-#[allow(non_snake_case)]
-pub fn expr_requires_semi_to_be_stmt_FIXME(e: &ast::Expr) -> bool {
-    !matches!(
-        e.kind,
-        ast::ExprKind::If(..)
-            | ast::ExprKind::Match(..)
-            | ast::ExprKind::Block(..)
-            | ast::ExprKind::While(..)
-            | ast::ExprKind::Loop(..)
-            | ast::ExprKind::ForLoop { .. }
-            | ast::ExprKind::TryBlock(..)
-            | ast::ExprKind::ConstBlock(..)
-    )
+pub fn expr_requires_semi_to_be_stmt(e: &ast::Expr) -> bool {
+    use ast::ExprKind::*;
+
+    match &e.kind {
+        If(..)
+        | Match(..)
+        | Block(..)
+        | While(..)
+        | Loop(..)
+        | ForLoop { .. }
+        | TryBlock(..)
+        | ConstBlock(..) => false,
+
+        MacCall(mac_call) => mac_call.args.delim != Delimiter::Brace,
+
+        _ => true,
+    }
 }
 
 /// If an expression ends with `}`, returns the innermost expression ending in the `}`