-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Closed
Closed
Copy link
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Description
Summary
The lint currently fails to trigger when a manually maintained loop counter does not start at 0.
Lint Name
Reproducer
I tried this code:
pub fn m1(v: Vec<u8>) {
let mut i = 1;
for item in &v {
black_box((i, *item));
i += 1;
}
}https://rust.godbolt.org/z/oG1h3f1nY
I expected to see this happen:
warning: the variable `i` is used as a loop counter
--> <source>:5:5
|
5 | for item in &v {
| ^^^^^^^^^^^^^^ help: consider using: `for (i, item) in (1..).zip(v.iter())`
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#explicit_counter_loop
= note: `#[warn(clippy::explicit_counter_loop)]` on by default
warning: 1 warning emitted
Instead, this happened:
Lint was not triggered.
Version
nightly
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingI-false-negativeIssue: The lint should have been triggered on code, but wasn'tIssue: The lint should have been triggered on code, but wasn't
Type
Fields
Give feedbackNo fields configured for issues without a type.