Open
Description
In this code we first create the mut range bound, and mutate it in another loop which means the loop that actually uses the range is executed several times with different bounds (even if it is true that inside the usage of the range, changing the index has no effect on the inner loop.
fn main() {
let mut i = 3;
while i < 1000 { // this invalidates the lint warning
for x in i..9 { // this will be unaffected by the i+=4 but we modify i AND LOOP AGAIN!
i += 4; // lint warns about this
}
if i > 12 {
return;
}
}
}
The lint should probably only fire if range bound variable and the range bounds usage are in the same scope?
Meta
clippy 0.0.212 (1fd5b9d 2020-09-20)