You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Incorrect suggestion in while_let_on_iterator if iterator cannot be moved #8113
warning: this loop could be written as a `for` loop
--> src\main.rs:3:5
|
3 | while let Some(x) = arr[0].next() {}
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: try: `for x in arr[0]`
|
= note: `#[warn(clippy::while_let_on_iterator)]` on by default
the suggestion causes the error
error[E0508]: cannot move out of type `[std::vec::IntoIter<i32>; 1]`, a non-copy array
--> src\main.rs:3:14
|
3 | for x in arr[0] {}
| ^^^^^^
| |
| cannot move out of here
| move occurs because `arr[_]` has type `std::vec::IntoIter<i32>`, which does not implement the `Copy` trait
changed the title [-]False positive in `while_let_on_iterator` if iterator cannot be moved[/-][+]Incorrect suggestion in `while_let_on_iterator` if iterator cannot be moved[/+]on Dec 9, 2021
Activity
WaffleLapkin commentedon Dec 9, 2021
I don't think it's false positive, as there can be correct suggestion:
i.e. if iterator can't be moved we should suggest using unique references to the said iterator
[-]False positive in `while_let_on_iterator` if iterator cannot be moved[/-][+]Incorrect suggestion in `while_let_on_iterator` if iterator cannot be moved[/+]Alexendoo commentedon Dec 9, 2021
@rustbot label -I-suggestion-causes-error
Alexendoo commentedon Dec 9, 2021
Whoops, wrong one 👀
@rustbot label +I-suggestion-causes-error -I-false-positive
Auto merge of #8221 - Jarcho:while_let_on_iterator_8113, r=llogiq
Auto merge of #8221 - Jarcho:while_let_on_iterator_8113, r=llogiq