Skip to content

Commit ff6c7c5

Browse files
committed
Fix pretty printer statement boundaries after braced macro call
1 parent 56207f6 commit ff6c7c5

File tree

2 files changed

+4
-7
lines changed

2 files changed

+4
-7
lines changed

compiler/rustc_ast_pretty/src/pprust/state/expr.rs

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -470,11 +470,8 @@ impl<'a> State<'a> {
470470
//
471471
// Same applies to a small set of other expression kinds which eagerly
472472
// terminate a statement which opens with them.
473-
let needs_par = fixup.leftmost_subexpression_in_stmt
474-
&& match expr.kind {
475-
ast::ExprKind::MacCall(_) => false,
476-
_ => !classify::expr_requires_semi_to_be_stmt(expr),
477-
};
473+
let needs_par =
474+
fixup.leftmost_subexpression_in_stmt && !classify::expr_requires_semi_to_be_stmt(expr);
478475
if needs_par {
479476
self.popen();
480477
fixup = FixupContext::default();

tests/ui/macros/stringify.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ fn test_expr() {
226226
);
227227
c2_match_arm!(
228228
[ m! {} - 1 ],
229-
"match () { _ => m! {} - 1, }",
229+
"match () { _ => (m! {}) - 1, }", // parenthesis is redundant
230230
"match() { _ => m! {} - 1 }",
231231
);
232232

@@ -748,7 +748,7 @@ fn test_stmt() {
748748
);
749749
c2_minus_one!(
750750
[ m! {} ],
751-
"m! {} - 1;", // FIXME(dtolnay): needs parens, otherwise this is 2 separate statements
751+
"(m! {}) - 1;",
752752
"m! {} - 1"
753753
);
754754

0 commit comments

Comments
 (0)