From 9e1cf2098d68356bccf7112bbff1d9b565e80a02 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 29 Dec 2023 16:30:34 -0800 Subject: 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. --- compiler/rustc_ast/src/util/classify.rs | 30 +++++++++++++++++------------- 1 file changed, 17 insertions(+), 13 deletions(-) (limited to 'compiler/rustc_ast/src') 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 `}` -- cgit 1.4.1-3-g733a5