mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-27 07:00:55 +00:00
Avoid deleting labeled blocks
This commit is contained in:
parent
b58b88c966
commit
abced206d7
3 changed files with 15 additions and 1 deletions
|
@ -357,7 +357,7 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<Vec
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
ExprKind::Block(block, _) => {
|
ExprKind::Block(block, _) => {
|
||||||
if block.stmts.is_empty() {
|
if block.stmts.is_empty() && !block.targeted_by_break {
|
||||||
block.expr.as_ref().and_then(|e| {
|
block.expr.as_ref().and_then(|e| {
|
||||||
match block.rules {
|
match block.rules {
|
||||||
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) => None,
|
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) => None,
|
||||||
|
|
|
@ -106,4 +106,11 @@ fn main() {
|
||||||
|
|
||||||
// Issue #11885
|
// Issue #11885
|
||||||
Cout << 16;
|
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
|
// Issue #11885
|
||||||
Cout << 16;
|
Cout << 16;
|
||||||
|
|
||||||
|
// Issue #11575
|
||||||
|
// Bad formatting is required to trigger the bug
|
||||||
|
#[rustfmt::skip]
|
||||||
|
'label: {
|
||||||
|
break 'label
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue