Auto merge of #9705 - jntrnr:disable_needless_collect, r=Manishearth
Move needless_collect to nursery *Please write a short comment explaining your change (or "none" for internal only changes)* changelog: [`needless_collect`]: Move `needless_collect` to nursery (Now allow-by-default) After chatting with a few folks, it seems like `needless_collect` is giving false positives pretty regularly (https://github.com/rust-lang/rust-clippy/issues?q=is%3Aissue+is%3Aopen+needless_collect). We're big supporters of clippy in Nushell, and it's one of the passes we require for CI, but we've had to disable this particular lint. Perhaps it should be moved to the nursery until it's improved? (apologies if this isn't the right approach to disabling a lint by default. I tried to follow the idea I saw other PRs doing in the past)
This commit is contained in:
commit
213003b887
@ -223,7 +223,7 @@ declare_clippy_lint! {
|
||||
/// ```
|
||||
#[clippy::version = "1.30.0"]
|
||||
pub NEEDLESS_COLLECT,
|
||||
perf,
|
||||
nursery,
|
||||
"collecting an iterator when collect is not needed"
|
||||
}
|
||||
|
||||
|
@ -1,4 +1,5 @@
|
||||
#![allow(clippy::uninlined_format_args)]
|
||||
#![warn(clippy::needless_collect)]
|
||||
|
||||
use std::collections::{BinaryHeap, HashMap, HashSet, LinkedList, VecDeque};
|
||||
|
||||
|
@ -1,5 +1,5 @@
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:7:39
|
||||
--> $DIR/needless_collect_indirect.rs:8:39
|
||||
|
|
||||
LL | let indirect_iter = sample.iter().collect::<Vec<_>>();
|
||||
| ^^^^^^^
|
||||
@ -14,7 +14,7 @@ LL ~ sample.iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:9:38
|
||||
--> $DIR/needless_collect_indirect.rs:10:38
|
||||
|
|
||||
LL | let indirect_len = sample.iter().collect::<VecDeque<_>>();
|
||||
| ^^^^^^^
|
||||
@ -28,7 +28,7 @@ LL ~ sample.iter().count();
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:11:40
|
||||
--> $DIR/needless_collect_indirect.rs:12:40
|
||||
|
|
||||
LL | let indirect_empty = sample.iter().collect::<VecDeque<_>>();
|
||||
| ^^^^^^^
|
||||
@ -42,7 +42,7 @@ LL ~ sample.iter().next().is_none();
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:13:43
|
||||
--> $DIR/needless_collect_indirect.rs:14:43
|
||||
|
|
||||
LL | let indirect_contains = sample.iter().collect::<VecDeque<_>>();
|
||||
| ^^^^^^^
|
||||
@ -56,7 +56,7 @@ LL ~ sample.iter().any(|x| x == &5);
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:25:48
|
||||
--> $DIR/needless_collect_indirect.rs:26:48
|
||||
|
|
||||
LL | let non_copy_contains = sample.into_iter().collect::<Vec<_>>();
|
||||
| ^^^^^^^
|
||||
@ -70,7 +70,7 @@ LL ~ sample.into_iter().any(|x| x == a);
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:54:51
|
||||
--> $DIR/needless_collect_indirect.rs:55:51
|
||||
|
|
||||
LL | let buffer: Vec<&str> = string.split('/').collect();
|
||||
| ^^^^^^^
|
||||
@ -84,7 +84,7 @@ LL ~ string.split('/').count()
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:59:55
|
||||
--> $DIR/needless_collect_indirect.rs:60:55
|
||||
|
|
||||
LL | let indirect_len: VecDeque<_> = sample.iter().collect();
|
||||
| ^^^^^^^
|
||||
@ -98,7 +98,7 @@ LL ~ sample.iter().count()
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:64:57
|
||||
--> $DIR/needless_collect_indirect.rs:65:57
|
||||
|
|
||||
LL | let indirect_len: LinkedList<_> = sample.iter().collect();
|
||||
| ^^^^^^^
|
||||
@ -112,7 +112,7 @@ LL ~ sample.iter().count()
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:69:57
|
||||
--> $DIR/needless_collect_indirect.rs:70:57
|
||||
|
|
||||
LL | let indirect_len: BinaryHeap<_> = sample.iter().collect();
|
||||
| ^^^^^^^
|
||||
@ -126,7 +126,7 @@ LL ~ sample.iter().count()
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:129:59
|
||||
--> $DIR/needless_collect_indirect.rs:130:59
|
||||
|
|
||||
LL | let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
|
||||
| ^^^^^^^
|
||||
@ -143,7 +143,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == i);
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:154:59
|
||||
--> $DIR/needless_collect_indirect.rs:155:59
|
||||
|
|
||||
LL | let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
|
||||
| ^^^^^^^
|
||||
@ -160,7 +160,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == n);
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:183:63
|
||||
--> $DIR/needless_collect_indirect.rs:184:63
|
||||
|
|
||||
LL | let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
|
||||
| ^^^^^^^
|
||||
@ -177,7 +177,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == n);
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:219:59
|
||||
--> $DIR/needless_collect_indirect.rs:220:59
|
||||
|
|
||||
LL | let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
|
||||
| ^^^^^^^
|
||||
@ -195,7 +195,7 @@ LL ~ vec.iter().map(|k| k * k).any(|x| x == n);
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:244:26
|
||||
--> $DIR/needless_collect_indirect.rs:245:26
|
||||
|
|
||||
LL | let w = v.iter().collect::<Vec<_>>();
|
||||
| ^^^^^^^
|
||||
@ -211,7 +211,7 @@ LL ~ for _ in 0..v.iter().count() {
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:266:30
|
||||
--> $DIR/needless_collect_indirect.rs:267:30
|
||||
|
|
||||
LL | let mut w = v.iter().collect::<Vec<_>>();
|
||||
| ^^^^^^^
|
||||
@ -227,7 +227,7 @@ LL ~ while 1 == v.iter().count() {
|
||||
|
|
||||
|
||||
error: avoid using `collect()` when not needed
|
||||
--> $DIR/needless_collect_indirect.rs:288:30
|
||||
--> $DIR/needless_collect_indirect.rs:289:30
|
||||
|
|
||||
LL | let mut w = v.iter().collect::<Vec<_>>();
|
||||
| ^^^^^^^
|
||||
|
Loading…
x
Reference in New Issue
Block a user