-
Notifications
You must be signed in to change notification settings - Fork 1.8k
Open
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onCall for participation: This a hard problem and requires more experience or effort to work onI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have
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)
tony84727 and Enyium
Metadata
Metadata
Assignees
Labels
C-bugCategory: Clippy is not doing the correct thingCategory: Clippy is not doing the correct thingE-hardCall for participation: This a hard problem and requires more experience or effort to work onCall for participation: This a hard problem and requires more experience or effort to work onI-false-positiveIssue: The lint was triggered on code it shouldn't haveIssue: The lint was triggered on code it shouldn't have