Skip to content

Commit ad47776

Browse files
committed
Fix pretty printer statement boundaries after braced macro call
1 parent 1c84319 commit ad47776

File tree

2 files changed

+3
-7
lines changed

2 files changed

+3
-7
lines changed

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

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,7 @@ impl FixupContext {
128128
/// The documentation on `FixupContext::leftmost_subexpression_in_stmt` has
129129
/// examples.
130130
pub fn would_cause_statement_boundary(self, expr: &Expr) -> bool {
131-
self.leftmost_subexpression_in_stmt
132-
&& match expr.kind {
133-
ExprKind::MacCall(_) => false,
134-
_ => !classify::expr_requires_semi_to_be_stmt(expr),
135-
}
131+
self.leftmost_subexpression_in_stmt && !classify::expr_requires_semi_to_be_stmt(expr)
136132
}
137133

138134
/// Determine whether parentheses are needed around the given `let`

tests/ui/macros/stringify.rs

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

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

0 commit comments

Comments
 (0)