-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Closed
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
Description
Summary
Seems like the never_loop lint ignores any continue statements that are inside the else blocks in let..else statements. This produces a false positive.
Lint Name
never_loop
Reproducer
I tried this code:
#![feature(let_else)]
fn test(a: Option<usize>) {
loop {
// doesn't trigger lint:
// if let Some(a) = a {
let Some(a) = a else {
continue;
};
break;
}
}I saw this happen:
error: this loop never actually loops
--> src/lib.rs:6:5
|
6 | / loop {
7 | | // doesn't trigger lint: if let Some(a) = a {
8 | | let Some(a) = a else {
9 | | continue;
... |
14 | | break;
15 | | }
| |_____^
|
= note: `#[deny(clippy::never_loop)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#never_loop
I expected to see this happen:
never_loop should not be triggered.
Version
rustc 1.65.0-nightly (86c6ebee8 2022-08-16)
binary: rustc
commit-hash: 86c6ebee8fa0a5ad1e18e375113b06bd2849b634
commit-date: 2022-08-16
host: x86_64-unknown-linux-gnu
release: 1.65.0-nightly
LLVM version: 15.0.0
Additional Labels
No response
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have