]> git.lizzy.rs Git - rust.git/blob - tests/ui/for_loop.stderr
Merge pull request #2984 from flip1995/single_char_pattern
[rust.git] / tests / ui / for_loop.stderr
1 error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement.
2   --> $DIR/for_loop.rs:17:14
3    |
4 17 |     for x in option {
5    |              ^^^^^^
6    |
7    = note: `-D for-loop-over-option` implied by `-D warnings`
8    = help: consider replacing `for x in option` with `if let Some(x) = option`
9
10 error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement.
11   --> $DIR/for_loop.rs:22:14
12    |
13 22 |     for x in result {
14    |              ^^^^^^
15    |
16    = note: `-D for-loop-over-result` implied by `-D warnings`
17    = help: consider replacing `for x in result` with `if let Ok(x) = result`
18
19 error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement.
20   --> $DIR/for_loop.rs:26:14
21    |
22 26 |     for x in option.ok_or("x not found") {
23    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^
24    |
25    = help: consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")`
26
27 error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
28   --> $DIR/for_loop.rs:32:14
29    |
30 32 |     for x in v.iter().next() {
31    |              ^^^^^^^^^^^^^^^
32    |
33    = note: `-D iter-next-loop` implied by `-D warnings`
34
35 error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement.
36   --> $DIR/for_loop.rs:37:14
37    |
38 37 |     for x in v.iter().next().and(Some(0)) {
39    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
40    |
41    = help: consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))`
42
43 error: for loop over `v.iter().next().ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement.
44   --> $DIR/for_loop.rs:41:14
45    |
46 41 |     for x in v.iter().next().ok_or("x not found") {
47    |              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
48    |
49    = help: consider replacing `for x in v.iter().next().ok_or("x not found")` with `if let Ok(x) = v.iter().next().ok_or("x not found")`
50
51 error: this loop never actually loops
52   --> $DIR/for_loop.rs:53:5
53    |
54 53 | /     while let Some(x) = option {
55 54 | |         println!("{}", x);
56 55 | |         break;
57 56 | |     }
58    | |_____^
59    |
60    = note: `-D never-loop` implied by `-D warnings`
61
62 error: this loop never actually loops
63   --> $DIR/for_loop.rs:59:5
64    |
65 59 | /     while let Ok(x) = result {
66 60 | |         println!("{}", x);
67 61 | |         break;
68 62 | |     }
69    | |_____^
70
71 error: the loop variable `i` is only used to index `vec`.
72   --> $DIR/for_loop.rs:86:14
73    |
74 86 |     for i in 0..vec.len() {
75    |              ^^^^^^^^^^^^
76    |
77    = note: `-D needless-range-loop` implied by `-D warnings`
78 help: consider using an iterator
79    |
80 86 |     for <item> in &vec {
81    |         ^^^^^^    ^^^^
82
83 error: the loop variable `i` is only used to index `vec`.
84   --> $DIR/for_loop.rs:95:14
85    |
86 95 |     for i in 0..vec.len() {
87    |              ^^^^^^^^^^^^
88 help: consider using an iterator
89    |
90 95 |     for <item> in &vec {
91    |         ^^^^^^    ^^^^
92
93 error: the loop variable `j` is only used to index `STATIC`.
94    --> $DIR/for_loop.rs:100:14
95     |
96 100 |     for j in 0..4 {
97     |              ^^^^
98 help: consider using an iterator
99     |
100 100 |     for <item> in STATIC.iter().take(4) {
101     |         ^^^^^^    ^^^^^^^^^^^^^^^^^^^^^
102
103 error: the loop variable `j` is only used to index `CONST`.
104    --> $DIR/for_loop.rs:104:14
105     |
106 104 |     for j in 0..4 {
107     |              ^^^^
108 help: consider using an iterator
109     |
110 104 |     for <item> in CONST.iter().take(4) {
111     |         ^^^^^^    ^^^^^^^^^^^^^^^^^^^^
112
113 error: the loop variable `i` is used to index `vec`
114    --> $DIR/for_loop.rs:108:14
115     |
116 108 |     for i in 0..vec.len() {
117     |              ^^^^^^^^^^^^
118 help: consider using an iterator
119     |
120 108 |     for (i, <item>) in vec.iter().enumerate() {
121     |         ^^^^^^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^
122
123 error: the loop variable `i` is only used to index `vec2`.
124    --> $DIR/for_loop.rs:116:14
125     |
126 116 |     for i in 0..vec.len() {
127     |              ^^^^^^^^^^^^
128 help: consider using an iterator
129     |
130 116 |     for <item> in vec2.iter().take(vec.len()) {
131     |         ^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
132
133 error: the loop variable `i` is only used to index `vec`.
134    --> $DIR/for_loop.rs:120:14
135     |
136 120 |     for i in 5..vec.len() {
137     |              ^^^^^^^^^^^^
138 help: consider using an iterator
139     |
140 120 |     for <item> in vec.iter().skip(5) {
141     |         ^^^^^^    ^^^^^^^^^^^^^^^^^^
142
143 error: the loop variable `i` is only used to index `vec`.
144    --> $DIR/for_loop.rs:124:14
145     |
146 124 |     for i in 0..MAX_LEN {
147     |              ^^^^^^^^^^
148 help: consider using an iterator
149     |
150 124 |     for <item> in vec.iter().take(MAX_LEN) {
151     |         ^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^^^
152
153 error: the loop variable `i` is only used to index `vec`.
154    --> $DIR/for_loop.rs:128:14
155     |
156 128 |     for i in 0..=MAX_LEN {
157     |              ^^^^^^^^^^^
158 help: consider using an iterator
159     |
160 128 |     for <item> in vec.iter().take(MAX_LEN + 1) {
161     |         ^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
162
163 error: the loop variable `i` is only used to index `vec`.
164    --> $DIR/for_loop.rs:132:14
165     |
166 132 |     for i in 5..10 {
167     |              ^^^^^
168 help: consider using an iterator
169     |
170 132 |     for <item> in vec.iter().take(10).skip(5) {
171     |         ^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^^^^^^
172
173 error: the loop variable `i` is only used to index `vec`.
174    --> $DIR/for_loop.rs:136:14
175     |
176 136 |     for i in 5..=10 {
177     |              ^^^^^^
178 help: consider using an iterator
179     |
180 136 |     for <item> in vec.iter().take(10 + 1).skip(5) {
181     |         ^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
182
183 error: the loop variable `i` is used to index `vec`
184    --> $DIR/for_loop.rs:140:14
185     |
186 140 |     for i in 5..vec.len() {
187     |              ^^^^^^^^^^^^
188 help: consider using an iterator
189     |
190 140 |     for (i, <item>) in vec.iter().enumerate().skip(5) {
191     |         ^^^^^^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
192
193 error: the loop variable `i` is used to index `vec`
194    --> $DIR/for_loop.rs:144:14
195     |
196 144 |     for i in 5..10 {
197     |              ^^^^^
198 help: consider using an iterator
199     |
200 144 |     for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
201     |         ^^^^^^^^^^^    ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
202
203 error: this range is empty so this for loop will never run
204    --> $DIR/for_loop.rs:148:14
205     |
206 148 |     for i in 10..0 {
207     |              ^^^^^
208     |
209     = note: `-D reverse-range-loop` implied by `-D warnings`
210 help: consider using the following if you are attempting to iterate over this range in reverse
211     |
212 148 |     for i in (0..10).rev() {
213     |              ^^^^^^^^^^^^^
214
215 error: this range is empty so this for loop will never run
216    --> $DIR/for_loop.rs:152:14
217     |
218 152 |     for i in 10..=0 {
219     |              ^^^^^^
220 help: consider using the following if you are attempting to iterate over this range in reverse
221     |
222 152 |     for i in (0...10).rev() {
223     |              ^^^^^^^^^^^^^^
224
225 error: this range is empty so this for loop will never run
226    --> $DIR/for_loop.rs:156:14
227     |
228 156 |     for i in MAX_LEN..0 {
229     |              ^^^^^^^^^^
230 help: consider using the following if you are attempting to iterate over this range in reverse
231     |
232 156 |     for i in (0..MAX_LEN).rev() {
233     |              ^^^^^^^^^^^^^^^^^^
234
235 error: this range is empty so this for loop will never run
236    --> $DIR/for_loop.rs:160:14
237     |
238 160 |     for i in 5..5 {
239     |              ^^^^
240
241 error: this range is empty so this for loop will never run
242    --> $DIR/for_loop.rs:185:14
243     |
244 185 |     for i in 10..5 + 4 {
245     |              ^^^^^^^^^
246 help: consider using the following if you are attempting to iterate over this range in reverse
247     |
248 185 |     for i in (5 + 4..10).rev() {
249     |              ^^^^^^^^^^^^^^^^^
250
251 error: this range is empty so this for loop will never run
252    --> $DIR/for_loop.rs:189:14
253     |
254 189 |     for i in (5 + 2)..(3 - 1) {
255     |              ^^^^^^^^^^^^^^^^
256 help: consider using the following if you are attempting to iterate over this range in reverse
257     |
258 189 |     for i in ((3 - 1)..(5 + 2)).rev() {
259     |              ^^^^^^^^^^^^^^^^^^^^^^^^
260
261 error: this range is empty so this for loop will never run
262    --> $DIR/for_loop.rs:193:14
263     |
264 193 |     for i in (5 + 2)..(8 - 1) {
265     |              ^^^^^^^^^^^^^^^^
266
267 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
268    --> $DIR/for_loop.rs:215:15
269     |
270 215 |     for _v in vec.iter() {}
271     |               ^^^^^^^^^^ help: to write this more concisely, try: `&vec`
272     |
273     = note: `-D explicit-iter-loop` implied by `-D warnings`
274
275 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
276    --> $DIR/for_loop.rs:217:15
277     |
278 217 |     for _v in vec.iter_mut() {}
279     |               ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec`
280
281 error: it is more idiomatic to loop over containers instead of using explicit iteration methods`
282    --> $DIR/for_loop.rs:220:15
283     |
284 220 |     for _v in out_vec.into_iter() {}
285     |               ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec`
286     |
287     = note: `-D explicit-into-iter-loop` implied by `-D warnings`
288
289 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
290    --> $DIR/for_loop.rs:223:15
291     |
292 223 |     for _v in array.into_iter() {}
293     |               ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&array`
294
295 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
296    --> $DIR/for_loop.rs:228:15
297     |
298 228 |     for _v in [1, 2, 3].iter() {}
299     |               ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]`
300
301 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
302    --> $DIR/for_loop.rs:232:15
303     |
304 232 |     for _v in [0; 32].iter() {}
305     |               ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]`
306
307 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
308    --> $DIR/for_loop.rs:237:15
309     |
310 237 |     for _v in ll.iter() {}
311     |               ^^^^^^^^^ help: to write this more concisely, try: `&ll`
312
313 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
314    --> $DIR/for_loop.rs:240:15
315     |
316 240 |     for _v in vd.iter() {}
317     |               ^^^^^^^^^ help: to write this more concisely, try: `&vd`
318
319 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
320    --> $DIR/for_loop.rs:243:15
321     |
322 243 |     for _v in bh.iter() {}
323     |               ^^^^^^^^^ help: to write this more concisely, try: `&bh`
324
325 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
326    --> $DIR/for_loop.rs:246:15
327     |
328 246 |     for _v in hm.iter() {}
329     |               ^^^^^^^^^ help: to write this more concisely, try: `&hm`
330
331 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
332    --> $DIR/for_loop.rs:249:15
333     |
334 249 |     for _v in bt.iter() {}
335     |               ^^^^^^^^^ help: to write this more concisely, try: `&bt`
336
337 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
338    --> $DIR/for_loop.rs:252:15
339     |
340 252 |     for _v in hs.iter() {}
341     |               ^^^^^^^^^ help: to write this more concisely, try: `&hs`
342
343 error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
344    --> $DIR/for_loop.rs:255:15
345     |
346 255 |     for _v in bs.iter() {}
347     |               ^^^^^^^^^ help: to write this more concisely, try: `&bs`
348
349 error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
350    --> $DIR/for_loop.rs:257:15
351     |
352 257 |     for _v in vec.iter().next() {}
353     |               ^^^^^^^^^^^^^^^^^
354
355 error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator
356    --> $DIR/for_loop.rs:264:5
357     |
358 264 |     vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>();
359     |     ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
360     |
361     = note: `-D unused-collect` implied by `-D warnings`
362
363 error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
364    --> $DIR/for_loop.rs:269:15
365     |
366 269 |     for _v in &vec {
367     |               ^^^^
368     |
369     = note: `-D explicit-counter-loop` implied by `-D warnings`
370
371 error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
372    --> $DIR/for_loop.rs:275:15
373     |
374 275 |     for _v in &vec {
375     |               ^^^^
376
377 error: you seem to want to iterate on a map's values
378    --> $DIR/for_loop.rs:385:19
379     |
380 385 |     for (_, v) in &m {
381     |                   ^^
382     |
383     = note: `-D for-kv-map` implied by `-D warnings`
384 help: use the corresponding method
385     |
386 385 |     for v in m.values() {
387     |         ^    ^^^^^^^^^^
388
389 error: you seem to want to iterate on a map's values
390    --> $DIR/for_loop.rs:390:19
391     |
392 390 |     for (_, v) in &*m {
393     |                   ^^^
394 help: use the corresponding method
395     |
396 390 |     for v in (*m).values() {
397     |         ^    ^^^^^^^^^^^^^
398
399 error: you seem to want to iterate on a map's values
400    --> $DIR/for_loop.rs:398:19
401     |
402 398 |     for (_, v) in &mut m {
403     |                   ^^^^^^
404 help: use the corresponding method
405     |
406 398 |     for v in m.values_mut() {
407     |         ^    ^^^^^^^^^^^^^^
408
409 error: you seem to want to iterate on a map's values
410    --> $DIR/for_loop.rs:403:19
411     |
412 403 |     for (_, v) in &mut *m {
413     |                   ^^^^^^^
414 help: use the corresponding method
415     |
416 403 |     for v in (*m).values_mut() {
417     |         ^    ^^^^^^^^^^^^^^^^^
418
419 error: you seem to want to iterate on a map's keys
420    --> $DIR/for_loop.rs:409:24
421     |
422 409 |     for (k, _value) in rm {
423     |                        ^^
424 help: use the corresponding method
425     |
426 409 |     for k in rm.keys() {
427     |         ^    ^^^^^^^^^
428
429 error: it looks like you're manually copying between slices
430    --> $DIR/for_loop.rs:462:14
431     |
432 462 |     for i in 0..src.len() {
433     |              ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])`
434     |
435     = note: `-D manual-memcpy` implied by `-D warnings`
436
437 error: it looks like you're manually copying between slices
438    --> $DIR/for_loop.rs:467:14
439     |
440 467 |     for i in 0..src.len() {
441     |              ^^^^^^^^^^^^ help: try replacing the loop by: `dst[10..(src.len() + 10)].clone_from_slice(&src[..])`
442
443 error: it looks like you're manually copying between slices
444    --> $DIR/for_loop.rs:472:14
445     |
446 472 |     for i in 0..src.len() {
447     |              ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[10..])`
448
449 error: it looks like you're manually copying between slices
450    --> $DIR/for_loop.rs:477:14
451     |
452 477 |     for i in 11..src.len() {
453     |              ^^^^^^^^^^^^^ help: try replacing the loop by: `dst[11..src.len()].clone_from_slice(&src[(11 - 10)..(src.len() - 10)])`
454
455 error: it looks like you're manually copying between slices
456    --> $DIR/for_loop.rs:482:14
457     |
458 482 |     for i in 0..dst.len() {
459     |              ^^^^^^^^^^^^ help: try replacing the loop by: `dst.clone_from_slice(&src[..dst.len()])`
460
461 error: it looks like you're manually copying between slices
462    --> $DIR/for_loop.rs:495:14
463     |
464 495 |     for i in 10..256 {
465     |              ^^^^^^^
466 help: try replacing the loop by
467     |
468 495 |     for i in dst[10..256].clone_from_slice(&src[(10 - 5)..(256 - 5)])
469 496 |     dst2[(10 + 500)..(256 + 500)].clone_from_slice(&src[10..256]) {
470     |
471
472 error: it looks like you're manually copying between slices
473    --> $DIR/for_loop.rs:507:14
474     |
475 507 |     for i in 10..LOOP_OFFSET {
476     |              ^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst[(10 + LOOP_OFFSET)..(LOOP_OFFSET + LOOP_OFFSET)].clone_from_slice(&src[(10 - some_var)..(LOOP_OFFSET - some_var)])`
477
478 error: it looks like you're manually copying between slices
479    --> $DIR/for_loop.rs:520:14
480     |
481 520 |     for i in 0..src_vec.len() {
482     |              ^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst_vec[..src_vec.len()].clone_from_slice(&src_vec[..])`
483
484 error: it looks like you're manually copying between slices
485    --> $DIR/for_loop.rs:547:14
486     |
487 547 |     for i in 0..src.len() {
488     |              ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])`
489
490 error: aborting due to 59 previous errors
491