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
chyvonomys opened this issue
Sep 9, 2017
· 4 comments
Labels
C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.
Clippy reports needless_range_loop and suggests using iter/take/skip which is wrong for this case:
let ns = [2, 3, 5, 7];
for i in 3..10 {
println!("{}", ns[i % 4]);
}
warning: the loop variable `i` is only used to index `ns`.
--> src\main.rs:3:5
|
3 | / for i in 3..10 {
4 | | println!("{}", ns[i % 4]);
5 | | }
| |_____^
|
= note: #[warn(needless_range_loop)] on by default
= help: for further information visit https://rust-lang-nursery.github.io/rust-clippy/v0.0.158/index.html#needless_range_loop
help: consider using an iterator
|
3 | for <item> in ns.iter().take(10).skip(3) {
| ^^^^^^
The text was updated successfully, but these errors were encountered:
oli-obk
added
E-medium
Call for participation: Medium difficulty level problem and requires some initial experience.
C-bug
Category: Clippy is not doing the correct thing
labels
Sep 10, 2017
I think it would be better to make it work as before, i.e. to report cases like ns[i] only. Expression under [...] may be more complex than just i % 4 and figuring out what iterator style equivalent to suggest seems to be a non-trivial task. Also, using just expression is better than iterator. At least in my example.
C-bugCategory: Clippy is not doing the correct thingE-mediumCall for participation: Medium difficulty level problem and requires some initial experience.
Clippy reports
needless_range_loop
and suggests using iter/take/skip which is wrong for this case:The text was updated successfully, but these errors were encountered: