Closed
Description
Summary
Having an internal labeled block which is always broken to causes a false positive on never_loop.
Lint Name
never_loop
Reproducer
I tried this code: (playground)
fn thing(iter: impl Iterator) {
for _ in iter {
'b: {
// error goes away if we just have the block's value be ().
break 'b;
}
}
}
I saw this error:
error: this loop never actually loops
--> src/lib.rs:2:5
|
2 | / for _ in iter {
3 | | 'b: {
4 | | break 'b;
5 | | }
6 | | }
| |_____^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#never_loop
= note: `#[deny(clippy::never_loop)]` on by default
help: if you need the first element of the iterator, try writing
|
2 | if let Some(_) = iter.next() {
| ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Version
rustc 1.67.0-nightly (e75aab045 2022-11-09)
binary: rustc
commit-hash: e75aab045fc476f176a58c408f6b06f0e275c6e1
commit-date: 2022-11-09
host: aarch64-apple-darwin
release: 1.67.0-nightly
LLVM version: 15.0.4
Additional Labels
No response