Skip to content

Commit c2ecb30

Browse files
committed
Do not flatten nested block with attributes on match arm
1 parent f84c399 commit c2ecb30

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

rustfmt-core/rustfmt-lib/src/matches.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,11 @@ fn flatten_arm_body<'a>(
299299
if let Some(ref block) = block_can_be_flattened(context, body) {
300300
if let ast::StmtKind::Expr(ref expr) = block.stmts[0].kind {
301301
if let ast::ExprKind::Block(..) = expr.kind {
302-
flatten_arm_body(context, expr, None)
302+
if expr.attrs.is_empty() {
303+
flatten_arm_body(context, expr, None)
304+
} else {
305+
(true, body)
306+
}
303307
} else {
304308
let cond_becomes_muti_line = opt_shape
305309
.and_then(|shape| rewrite_cond(context, expr, shape))

0 commit comments

Comments
 (0)