summaryrefslogtreecommitdiffstats
path: root/src/tools/clippy/tests/ui/needless_collect_indirect.stderr
blob: 0f5e78f91198c27dd50d74e25bce448c89207d37 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
error: avoid using `collect()` when not needed
  --> $DIR/needless_collect_indirect.rs:5: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:7: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:9: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:11: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:23: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:52: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:57: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:62: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:67: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: aborting due to 9 previous errors