Summary
needless_range_loop incorrectly complains about multi-level arrays.
Lint Name
needless_range_loop
Reproducer
I tried this code:
fn fun(a: [[usize; 5]; 5]) {
let mut sum = 0;
for i in 0..5 {
sum += a[sum % 5][i];
}
}
I saw this happen:
warning: the loop variable `i` is only used to index `a`
--> src/main.rs:4:14
|
4 | for i in 0..5 {
| ^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_range_loop
= note: `#[warn(clippy::needless_range_loop)]` on by default
help: consider using an iterator
|
4 - for i in 0..5 {
4 + for <item> in &a {
|
I expected to see this happen:
no warning
Version
Additional Labels
No response
Summary
needless_range_loopincorrectly complains about multi-level arrays.Lint Name
needless_range_loop
Reproducer
I tried this code:
I saw this happen:
I expected to see this happen:
no warning
Version
Additional Labels
No response