Skip to content

Commit 534fb07

Browse files
committed
Avoid deleting labeled blocks
1 parent b58b88c commit 534fb07

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

clippy_lints/src/no_effect.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -356,8 +356,8 @@ fn reduce_expression<'a>(cx: &LateContext<'_>, expr: &'a Expr<'a>) -> Option<Vec
356356
None
357357
}
358358
},
359-
ExprKind::Block(block, _) => {
360-
if block.stmts.is_empty() {
359+
ExprKind::Block(block, label) => {
360+
if block.stmts.is_empty() && label.is_none() {
361361
block.expr.as_ref().and_then(|e| {
362362
match block.rules {
363363
BlockCheckMode::UnsafeBlock(UnsafeSource::UserProvided) => None,

tests/ui/unnecessary_operation.fixed

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,4 +106,9 @@ fn main() {
106106

107107
// Issue #11885
108108
Cout << 16;
109+
110+
// Issue #11575
111+
'label: {
112+
break 'label
113+
};
109114
}

tests/ui/unnecessary_operation.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,4 +110,9 @@ fn main() {
110110

111111
// Issue #11885
112112
Cout << 16;
113+
114+
// Issue #11575
115+
'label: {
116+
break 'label
117+
};
113118
}

0 commit comments

Comments
 (0)