Auto merge of #13648 - samueltardieu:push-rpxvoukpolvm, r=Centri3

needless_continue: check labels consistency before warning

changelog: [`needless_continue`]: check labels before warning about `continue` as the last statement in a loop body

Fix #13641
This commit is contained in:
bors 2024-11-03 23:17:36 +00:00
commit ccf7c88386
3 changed files with 29 additions and 3 deletions

View file

@ -151,3 +151,20 @@ mod issue_2329 {
}
}
}
fn issue_13641() {
'a: while std::hint::black_box(true) {
#[allow(clippy::never_loop)]
loop {
continue 'a;
}
}
#[allow(clippy::never_loop)]
while std::hint::black_box(true) {
'b: loop {
continue 'b;
//~^ ERROR: this `continue` expression is redundant
}
}
}

View file

@ -136,5 +136,13 @@ LL | | }
println!("bar-5");
}
error: aborting due to 8 previous errors
error: this `continue` expression is redundant
--> tests/ui/needless_continue.rs:166:13
|
LL | continue 'b;
| ^^^^^^^^^^^^
|
= help: consider dropping the `continue` expression
error: aborting due to 9 previous errors