-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
These two for loops are equivalent yet needless_range_loop
triggers for the second. I would expect it to trigger for none of them, since in both cases the loop variable is being used to index two arrays in parallel.
fn needless_loop() {
let x = [0; 64];
// ok
for i in 0..64 {
let y = [0; 64];
black_box(x[i]);
black_box(y[i]);
}
// consider using an iterator and enumerate(): `(i, <item>)`, `x.iter().enumerate()`
for i in 0..64 {
black_box(x[i]);
black_box([0; 64][i]);
}
}
> cargo clippy --version
clippy 0.1.90 (e466296627 2025-07-17)
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