Skip to content

Commit e86c2ba

Browse files
ytmimicalebcartwright
authored andcommitted
Don't flatten blocks that have labels
1 parent d8aeaba commit e86c2ba

File tree

2 files changed

+11
-2
lines changed

2 files changed

+11
-2
lines changed

Diff for: src/matches.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -306,8 +306,9 @@ fn block_can_be_flattened<'a>(
306306
expr: &'a ast::Expr,
307307
) -> Option<&'a ast::Block> {
308308
match expr.kind {
309-
ast::ExprKind::Block(ref block, _)
310-
if !is_unsafe_block(block)
309+
ast::ExprKind::Block(ref block, label)
310+
if label.is_none()
311+
&& !is_unsafe_block(block)
311312
&& !context.inside_macro()
312313
&& is_simple_block(context, block, Some(&expr.attrs))
313314
&& !stmt_is_expr_mac(&block.stmts[0]) =>

Diff for: tests/target/issue_5676.rs

+8
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
fn main() {
2+
match true {
3+
true => 'a: {
4+
break 'a;
5+
}
6+
_ => (),
7+
}
8+
}

0 commit comments

Comments
 (0)