rust-clippy/tests/ui/needless_collect_indirect.stderr
Yuri Astrakhan eb3970285b fallout: fix tests to allow uninlined_format_args
In order to switch `clippy::uninlined_format_args` from pedantic to
style, all existing tests must not raise a warning. I did not want to
change the actual tests, so this is a relatively minor change that:

* add `#![allow(clippy::uninlined_format_args)]` where needed
* normalizes all allow/deny/warn attributes
   * all allow attributes are grouped together
   * sorted alphabetically
   * the `clippy::*` attributes are listed separate from the other ones.
   * deny and warn attributes are listed before the allowed ones

changelog: none
2022-10-02 15:13:22 -04:00

246 lines
8.6 KiB
Text

error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:7:39
|
LL | let indirect_iter = sample.iter().collect::<Vec<_>>();
| ^^^^^^^
LL | indirect_iter.into_iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
| ------------------------- the iterator could be used here instead
|
= note: `-D clippy::needless-collect` implied by `-D warnings`
help: use the original Iterator instead of collecting it and then producing a new one
|
LL ~
LL ~ sample.iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:9:38
|
LL | let indirect_len = sample.iter().collect::<VecDeque<_>>();
| ^^^^^^^
LL | indirect_len.len();
| ------------------ the iterator could be used here instead
|
help: take the original Iterator's count instead of collecting it and finding the length
|
LL ~
LL ~ sample.iter().count();
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:11:40
|
LL | let indirect_empty = sample.iter().collect::<VecDeque<_>>();
| ^^^^^^^
LL | indirect_empty.is_empty();
| ------------------------- the iterator could be used here instead
|
help: check if the original Iterator has anything instead of collecting it and seeing if it's empty
|
LL ~
LL ~ sample.iter().next().is_none();
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:13:43
|
LL | let indirect_contains = sample.iter().collect::<VecDeque<_>>();
| ^^^^^^^
LL | indirect_contains.contains(&&5);
| ------------------------------- the iterator could be used here instead
|
help: check if the original Iterator contains an element instead of collecting then checking
|
LL ~
LL ~ sample.iter().any(|x| x == &5);
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:25:48
|
LL | let non_copy_contains = sample.into_iter().collect::<Vec<_>>();
| ^^^^^^^
LL | non_copy_contains.contains(&a);
| ------------------------------ the iterator could be used here instead
|
help: check if the original Iterator contains an element instead of collecting then checking
|
LL ~
LL ~ sample.into_iter().any(|x| x == a);
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:54:51
|
LL | let buffer: Vec<&str> = string.split('/').collect();
| ^^^^^^^
LL | buffer.len()
| ------------ the iterator could be used here instead
|
help: take the original Iterator's count instead of collecting it and finding the length
|
LL ~
LL ~ string.split('/').count()
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:59:55
|
LL | let indirect_len: VecDeque<_> = sample.iter().collect();
| ^^^^^^^
LL | indirect_len.len()
| ------------------ the iterator could be used here instead
|
help: take the original Iterator's count instead of collecting it and finding the length
|
LL ~
LL ~ sample.iter().count()
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:64:57
|
LL | let indirect_len: LinkedList<_> = sample.iter().collect();
| ^^^^^^^
LL | indirect_len.len()
| ------------------ the iterator could be used here instead
|
help: take the original Iterator's count instead of collecting it and finding the length
|
LL ~
LL ~ sample.iter().count()
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:69:57
|
LL | let indirect_len: BinaryHeap<_> = sample.iter().collect();
| ^^^^^^^
LL | indirect_len.len()
| ------------------ the iterator could be used here instead
|
help: take the original Iterator's count instead of collecting it and finding the length
|
LL ~
LL ~ sample.iter().count()
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:129:59
|
LL | let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
| ^^^^^^^
...
LL | y.contains(&i);
| -------------- the iterator could be used here instead
|
help: check if the original Iterator contains an element instead of collecting then checking
|
LL ~
LL | let z: Vec<usize> = vec.iter().map(|k| k * k).collect();
LL | // Do lint
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
|
LL | let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
| ^^^^^^^
...
LL | y.contains(&n);
| -------------- the iterator could be used here instead
|
help: check if the original Iterator contains an element instead of collecting then checking
|
LL ~
LL | let z: Vec<usize> = vec.iter().map(|k| k * k).collect();
LL | // Do lint
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
|
LL | let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
| ^^^^^^^
...
LL | y.contains(&n);
| -------------- the iterator could be used here instead
|
help: check if the original Iterator contains an element instead of collecting then checking
|
LL ~
LL | let z: Vec<usize> = vec.iter().map(|k| k * k).collect();
LL | // Do lint
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
|
LL | let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
| ^^^^^^^
...
LL | y.contains(&n);
| -------------- the iterator could be used here instead
|
help: check if the original Iterator contains an element instead of collecting then checking
|
LL ~
LL | let z: Vec<usize> = vec.iter().map(|k| k * k).collect();
LL | if n < 2 {
LL | // Do lint
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
|
LL | let w = v.iter().collect::<Vec<_>>();
| ^^^^^^^
LL | // Do lint
LL | for _ in 0..w.len() {
| ------- the iterator could be used here instead
|
help: take the original Iterator's count instead of collecting it and finding the length
|
LL ~
LL | // Do lint
LL ~ for _ in 0..v.iter().count() {
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:266:30
|
LL | let mut w = v.iter().collect::<Vec<_>>();
| ^^^^^^^
LL | // Do lint
LL | while 1 == w.len() {
| ------- the iterator could be used here instead
|
help: take the original Iterator's count instead of collecting it and finding the length
|
LL ~
LL | // Do lint
LL ~ while 1 == v.iter().count() {
|
error: avoid using `collect()` when not needed
--> $DIR/needless_collect_indirect.rs:288:30
|
LL | let mut w = v.iter().collect::<Vec<_>>();
| ^^^^^^^
LL | // Do lint
LL | while let Some(i) = Some(w.len()) {
| ------- the iterator could be used here instead
|
help: take the original Iterator's count instead of collecting it and finding the length
|
LL ~
LL | // Do lint
LL ~ while let Some(i) = Some(v.iter().count()) {
|
error: aborting due to 16 previous errors