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
fnmain(){let v = vec![1,2,3,2,4];#[allow(clippy::needless_collect)]let v:Vec<i32> = v.into_iter().map(|x| x *2).collect();}
This code should not warn but it does.
warning: unused variable: `v`
--> src/main.rs:4:9
|
4 | let v: Vec<i32> = v.into_iter().map(|x| x * 2).collect();
| ^ help: if this is intentional, prefix it with an underscore: `_v`
|
= note: `#[warn(unused_variables)]` on by default
warning: avoid using `collect()` when not needed
--> src/main.rs:4:52
|
4 | let v: Vec<i32> = v.into_iter().map(|x| x * 2).collect();
| ------------- ^^^^^^^
| |
| the iterator could be used here instead
|
= note: `#[warn(clippy::needless_collect)]` on by default
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#needless_collect
help: use the original Iterator instead of collecting it and then producing a new one
|
4 | v.into_iter().map(|x| x * 2).map(|x| x * 2).collect();
| -- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
warning: 2 warnings emitted
Finished dev [unoptimized + debuginfo] target(s) in 0.68s
A global #![allow(clippy::needless_collect)] works though.. 🤔
I tried this code:
This code should not warn but it does.
A global
#![allow(clippy::needless_collect)]
works though.. 🤔Playground
Meta
clippy 0.1.54 (881c1ac 2021-05-08)
The text was updated successfully, but these errors were encountered: