rust-lang / rust-lang/rust-clippy
`infinite-loop` and `never_loop` trigger on the same loop 😆
Open
Nobody has claimed this yet.
C-bug
I-false-positive
L-correctness
L-restriction
- Dominant language
- Rust
- Stars
- 13.5k
- Forks
- 2.2k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 32
Description
#![warn(clippy::infinite_loop, clippy::never_loop)]
fn main() {
'outer2: loop {
let _: i32 = loop { loop { break 'outer2 } };
}
}
...
warning: this loop never actually loops
--> a.rs:4:22
|
4 | let _: i32 = loop { loop { break 'outer2 } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#never_loop
warning: infinite loop detected
--> a.rs:4:22
|
4 | let _: i32 = loop { loop { break 'outer2 } };
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#infinite_loop
note: the lint level is defined here
...
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reproducing the supplied Rust snippet with both clippy::infinite_loop and clippy::never_loop enabled, then inspect the implementations of those two lints and their existing tests. Determine the intended diagnostic for this control flow and verify that the final behavior is consistent rather than producing contradictory reports.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- rust
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100