fork/rust

git clone https://git.julia.blue/fork/rust

borsAuto merge of #103046 - JanBeh:PR_clarify_cmp_terminology, r=workingjubilee3bcad65fbf6

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