]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_collect.stderr
Majority of PR changes
[rust.git] / tests / ui / needless_collect.stderr
1 error: you are collecting an iterator to check its length
2  --> $DIR/needless_collect.rs:7:28
3   |
4 7 |     let len = sample.iter().collect::<Vec<_>>().len();
5   |                            ^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.count()`
6   |
7   = note: `-D needless-collect` implied by `-D warnings`
8
9 error: you are collecting an iterator to check if it is empty
10  --> $DIR/needless_collect.rs:8:21
11   |
12 8 |     if sample.iter().collect::<Vec<_>>().is_empty() {
13   |                     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.next().is_none()`
14
15 error: you are collecting an iterator to check if contains an element
16   --> $DIR/needless_collect.rs:11:27
17    |
18 11 |     sample.iter().cloned().collect::<Vec<_>>().contains(&1);
19    |                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.any(|&x| x == 1)`
20
21 error: you are collecting an iterator to check its length
22   --> $DIR/needless_collect.rs:12:34
23    |
24 12 |     sample.iter().map(|x| (x, x)).collect::<HashMap<_, _>>().len();
25    |                                  ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: consider replacing with: `.count()`
26
27 error: aborting due to 4 previous errors
28