Don't flatten blocks that have labels

This commit is contained in:
Yacin Tmimi 2023-01-26 13:50:18 -05:00 committed by Caleb Cartwright
parent d8aeabaee1
commit e86c2ba545
2 changed files with 11 additions and 2 deletions

View File

@ -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]) =>

View File

@ -0,0 +1,8 @@
fn main() {
match true {
true => 'a: {
break 'a;
}
_ => (),
}
}