Skip to content

Commit

Permalink
Don't flatten blocks that have labels
Browse files Browse the repository at this point in the history
  • Loading branch information
ytmimi authored and calebcartwright committed Aug 13, 2023
1 parent d8aeaba commit e86c2ba
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/matches.rs
Original file line number Diff line number Diff line change
Expand Up @@ -306,8 +306,9 @@ fn block_can_be_flattened<'a>(
expr: &'a ast::Expr,
) -> Option<&'a ast::Block> {
match expr.kind {
ast::ExprKind::Block(ref block, _)
if !is_unsafe_block(block)
ast::ExprKind::Block(ref block, label)
if label.is_none()
&& !is_unsafe_block(block)
&& !context.inside_macro()
&& is_simple_block(context, block, Some(&expr.attrs))
&& !stmt_is_expr_mac(&block.stmts[0]) =>
Expand Down
8 changes: 8 additions & 0 deletions tests/target/issue_5676.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
fn main() {
match true {
true => 'a: {
break 'a;
}
_ => (),
}
}

0 comments on commit e86c2ba

Please sign in to comment.