mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-23 15:23:46 +00:00
Auto merge of #12219 - sanxiyn:labeled-block, r=blyxyas
Avoid deleting labeled blocks Fix #11575. changelog: [`unnecessary_operation`]: skip labeled blocks
This commit is contained in:
commit
9fb41079ca
@ -357,7 +357,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<Vec
|
||||
}
|
||||
},
|
||||
ExprKind::Block(block, _) => {
|
||||
if block.stmts.is_empty() {
|
||||
if block.stmts.is_empty() && !block.targeted_by_break {
|
||||
block.expr.as_ref().and_then(|e| {
|
||||
match block.rules {
|
||||
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) => None,
|
||||
|
@ -106,4 +106,11 @@ fn main() {
|
||||
|
||||
// Issue #11885
|
||||
Cout << 16;
|
||||
|
||||
// Issue #11575
|
||||
// Bad formatting is required to trigger the bug
|
||||
#[rustfmt::skip]
|
||||
'label: {
|
||||
break 'label
|
||||
};
|
||||
}
|
||||
|
@ -110,4 +110,11 @@ fn main() {
|
||||
|
||||
// Issue #11885
|
||||
Cout << 16;
|
||||
|
||||
// Issue #11575
|
||||
// Bad formatting is required to trigger the bug
|
||||
#[rustfmt::skip]
|
||||
'label: {
|
||||
break 'label
|
||||
};
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user