]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_collect_indirect.stderr
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / needless_collect_indirect.stderr
1 error: avoid using `collect()` when not needed
2   --> $DIR/needless_collect_indirect.rs:7:39
3    |
4 LL |     let indirect_iter = sample.iter().collect::<Vec<_>>();
5    |                                       ^^^^^^^
6 LL |     indirect_iter.into_iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
7    |     ------------------------- the iterator could be used here instead
8    |
9    = note: `-D clippy::needless-collect` implied by `-D warnings`
10 help: use the original Iterator instead of collecting it and then producing a new one
11    |
12 LL ~     
13 LL ~     sample.iter().map(|x| (x, x + 1)).collect::<HashMap<_, _>>();
14    |
15
16 error: avoid using `collect()` when not needed
17   --> $DIR/needless_collect_indirect.rs:9:38
18    |
19 LL |     let indirect_len = sample.iter().collect::<VecDeque<_>>();
20    |                                      ^^^^^^^
21 LL |     indirect_len.len();
22    |     ------------------ the iterator could be used here instead
23    |
24 help: take the original Iterator's count instead of collecting it and finding the length
25    |
26 LL ~     
27 LL ~     sample.iter().count();
28    |
29
30 error: avoid using `collect()` when not needed
31   --> $DIR/needless_collect_indirect.rs:11:40
32    |
33 LL |     let indirect_empty = sample.iter().collect::<VecDeque<_>>();
34    |                                        ^^^^^^^
35 LL |     indirect_empty.is_empty();
36    |     ------------------------- the iterator could be used here instead
37    |
38 help: check if the original Iterator has anything instead of collecting it and seeing if it's empty
39    |
40 LL ~     
41 LL ~     sample.iter().next().is_none();
42    |
43
44 error: avoid using `collect()` when not needed
45   --> $DIR/needless_collect_indirect.rs:13:43
46    |
47 LL |     let indirect_contains = sample.iter().collect::<VecDeque<_>>();
48    |                                           ^^^^^^^
49 LL |     indirect_contains.contains(&&5);
50    |     ------------------------------- the iterator could be used here instead
51    |
52 help: check if the original Iterator contains an element instead of collecting then checking
53    |
54 LL ~     
55 LL ~     sample.iter().any(|x| x == &5);
56    |
57
58 error: avoid using `collect()` when not needed
59   --> $DIR/needless_collect_indirect.rs:25:48
60    |
61 LL |     let non_copy_contains = sample.into_iter().collect::<Vec<_>>();
62    |                                                ^^^^^^^
63 LL |     non_copy_contains.contains(&a);
64    |     ------------------------------ the iterator could be used here instead
65    |
66 help: check if the original Iterator contains an element instead of collecting then checking
67    |
68 LL ~     
69 LL ~     sample.into_iter().any(|x| x == a);
70    |
71
72 error: avoid using `collect()` when not needed
73   --> $DIR/needless_collect_indirect.rs:54:51
74    |
75 LL |         let buffer: Vec<&str> = string.split('/').collect();
76    |                                                   ^^^^^^^
77 LL |         buffer.len()
78    |         ------------ the iterator could be used here instead
79    |
80 help: take the original Iterator's count instead of collecting it and finding the length
81    |
82 LL ~         
83 LL ~         string.split('/').count()
84    |
85
86 error: avoid using `collect()` when not needed
87   --> $DIR/needless_collect_indirect.rs:59:55
88    |
89 LL |         let indirect_len: VecDeque<_> = sample.iter().collect();
90    |                                                       ^^^^^^^
91 LL |         indirect_len.len()
92    |         ------------------ the iterator could be used here instead
93    |
94 help: take the original Iterator's count instead of collecting it and finding the length
95    |
96 LL ~         
97 LL ~         sample.iter().count()
98    |
99
100 error: avoid using `collect()` when not needed
101   --> $DIR/needless_collect_indirect.rs:64:57
102    |
103 LL |         let indirect_len: LinkedList<_> = sample.iter().collect();
104    |                                                         ^^^^^^^
105 LL |         indirect_len.len()
106    |         ------------------ the iterator could be used here instead
107    |
108 help: take the original Iterator's count instead of collecting it and finding the length
109    |
110 LL ~         
111 LL ~         sample.iter().count()
112    |
113
114 error: avoid using `collect()` when not needed
115   --> $DIR/needless_collect_indirect.rs:69:57
116    |
117 LL |         let indirect_len: BinaryHeap<_> = sample.iter().collect();
118    |                                                         ^^^^^^^
119 LL |         indirect_len.len()
120    |         ------------------ the iterator could be used here instead
121    |
122 help: take the original Iterator's count instead of collecting it and finding the length
123    |
124 LL ~         
125 LL ~         sample.iter().count()
126    |
127
128 error: avoid using `collect()` when not needed
129   --> $DIR/needless_collect_indirect.rs:129:59
130    |
131 LL |             let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
132    |                                                           ^^^^^^^
133 ...
134 LL |             y.contains(&i);
135    |             -------------- the iterator could be used here instead
136    |
137 help: check if the original Iterator contains an element instead of collecting then checking
138    |
139 LL ~             
140 LL |             let z: Vec<usize> = vec.iter().map(|k| k * k).collect();
141 LL |             // Do lint
142 LL ~             vec.iter().map(|k| k * k).any(|x| x == i);
143    |
144
145 error: avoid using `collect()` when not needed
146   --> $DIR/needless_collect_indirect.rs:154:59
147    |
148 LL |             let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
149    |                                                           ^^^^^^^
150 ...
151 LL |             y.contains(&n);
152    |             -------------- the iterator could be used here instead
153    |
154 help: check if the original Iterator contains an element instead of collecting then checking
155    |
156 LL ~             
157 LL |             let z: Vec<usize> = vec.iter().map(|k| k * k).collect();
158 LL |             // Do lint
159 LL ~             vec.iter().map(|k| k * k).any(|x| x == n);
160    |
161
162 error: avoid using `collect()` when not needed
163   --> $DIR/needless_collect_indirect.rs:183:63
164    |
165 LL |                 let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
166    |                                                               ^^^^^^^
167 ...
168 LL |                 y.contains(&n);
169    |                 -------------- the iterator could be used here instead
170    |
171 help: check if the original Iterator contains an element instead of collecting then checking
172    |
173 LL ~                 
174 LL |                 let z: Vec<usize> = vec.iter().map(|k| k * k).collect();
175 LL |                 // Do lint
176 LL ~                 vec.iter().map(|k| k * k).any(|x| x == n);
177    |
178
179 error: avoid using `collect()` when not needed
180   --> $DIR/needless_collect_indirect.rs:219:59
181    |
182 LL |             let y: Vec<usize> = vec.iter().map(|k| k * k).collect();
183    |                                                           ^^^^^^^
184 ...
185 LL |                 y.contains(&n);
186    |                 -------------- the iterator could be used here instead
187    |
188 help: check if the original Iterator contains an element instead of collecting then checking
189    |
190 LL ~             
191 LL |             let z: Vec<usize> = vec.iter().map(|k| k * k).collect();
192 LL |             if n < 2 {
193 LL |                 // Do lint
194 LL ~                 vec.iter().map(|k| k * k).any(|x| x == n);
195    |
196
197 error: avoid using `collect()` when not needed
198   --> $DIR/needless_collect_indirect.rs:244:26
199    |
200 LL |         let w = v.iter().collect::<Vec<_>>();
201    |                          ^^^^^^^
202 LL |         // Do lint
203 LL |         for _ in 0..w.len() {
204    |                     ------- the iterator could be used here instead
205    |
206 help: take the original Iterator's count instead of collecting it and finding the length
207    |
208 LL ~         
209 LL |         // Do lint
210 LL ~         for _ in 0..v.iter().count() {
211    |
212
213 error: avoid using `collect()` when not needed
214   --> $DIR/needless_collect_indirect.rs:266:30
215    |
216 LL |         let mut w = v.iter().collect::<Vec<_>>();
217    |                              ^^^^^^^
218 LL |         // Do lint
219 LL |         while 1 == w.len() {
220    |                    ------- the iterator could be used here instead
221    |
222 help: take the original Iterator's count instead of collecting it and finding the length
223    |
224 LL ~         
225 LL |         // Do lint
226 LL ~         while 1 == v.iter().count() {
227    |
228
229 error: avoid using `collect()` when not needed
230   --> $DIR/needless_collect_indirect.rs:288:30
231    |
232 LL |         let mut w = v.iter().collect::<Vec<_>>();
233    |                              ^^^^^^^
234 LL |         // Do lint
235 LL |         while let Some(i) = Some(w.len()) {
236    |                                  ------- the iterator could be used here instead
237    |
238 help: take the original Iterator's count instead of collecting it and finding the length
239    |
240 LL ~         
241 LL |         // Do lint
242 LL ~         while let Some(i) = Some(v.iter().count()) {
243    |
244
245 error: aborting due to 16 previous errors
246