From 7f2ffbdbc6c0d5e1c7fabe0bef56ec49d10bfeab Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Wed, 27 Dec 2023 17:30:54 -0800 Subject: [PATCH] Fix pretty printer statement boundaries after braced macro call --- compiler/rustc_ast_pretty/src/pprust/state/fixup.rs | 6 +----- tests/ui/macros/stringify.rs | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/compiler/rustc_ast_pretty/src/pprust/state/fixup.rs b/compiler/rustc_ast_pretty/src/pprust/state/fixup.rs index 9934f972f9bf..d21cb82f83b2 100644 --- a/compiler/rustc_ast_pretty/src/pprust/state/fixup.rs +++ b/compiler/rustc_ast_pretty/src/pprust/state/fixup.rs @@ -128,11 +128,7 @@ impl FixupContext { /// The documentation on `FixupContext::leftmost_subexpression_in_stmt` has /// examples. pub fn would_cause_statement_boundary(self, expr: &Expr) -> bool { - self.leftmost_subexpression_in_stmt - && match expr.kind { - ExprKind::MacCall(_) => false, - _ => !classify::expr_requires_semi_to_be_stmt(expr), - } + self.leftmost_subexpression_in_stmt && !classify::expr_requires_semi_to_be_stmt(expr) } /// Determine whether parentheses are needed around the given `let` diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index df1cf5d8a910..a66a5513ffae 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -225,7 +225,7 @@ fn test_expr() { ); c2_match_arm!( [ m! {} - 1 ], - "match () { _ => m! {} - 1, }", + "match () { _ => (m! {}) - 1, }", // parenthesis is redundant "match () { _ => m! {} - 1 }", ); @@ -747,7 +747,7 @@ fn test_stmt() { ); c2_minus_one!( [ m! {} ], - "m! {} - 1;", // FIXME(dtolnay): needs parens, otherwise this is 2 separate statements + "(m! {}) - 1;", "m! {} - 1" );