rust/tests/ui/for_loop.stderr

492 lines
16 KiB
Plaintext
Raw Normal View History

error: for loop over `option`, which is an `Option`. This is more readably written as an `if let` statement.
--> $DIR/for_loop.rs:17:14
|
17 | for x in option {
| ^^^^^^
|
= note: `-D for-loop-over-option` implied by `-D warnings`
= help: consider replacing `for x in option` with `if let Some(x) = option`
error: for loop over `result`, which is a `Result`. This is more readably written as an `if let` statement.
2017-08-01 10:54:21 -05:00
--> $DIR/for_loop.rs:22:14
|
22 | for x in result {
| ^^^^^^
|
= note: `-D for-loop-over-result` implied by `-D warnings`
= help: consider replacing `for x in result` with `if let Ok(x) = result`
error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is more readably written as an `if let` statement.
2017-08-01 10:54:21 -05:00
--> $DIR/for_loop.rs:26:14
|
26 | for x in option.ok_or("x not found") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider replacing `for x in option.ok_or("x not found")` with `if let Ok(x) = option.ok_or("x not found")`
error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:32:14
|
2018-01-28 22:18:11 -06:00
32 | for x in v.iter().next() {
| ^^^^^^^^^^^^^^^
|
= note: `-D iter-next-loop` implied by `-D warnings`
error: for loop over `v.iter().next().and(Some(0))`, which is an `Option`. This is more readably written as an `if let` statement.
--> $DIR/for_loop.rs:37:14
|
37 | for x in v.iter().next().and(Some(0)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: consider replacing `for x in v.iter().next().and(Some(0))` with `if let Some(x) = v.iter().next().and(Some(0))`
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.
--> $DIR/for_loop.rs:41:14
|
41 | for x in v.iter().next().ok_or("x not found") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= 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")`
2017-05-31 23:22:15 -05:00
error: this loop never actually loops
--> $DIR/for_loop.rs:53:5
2017-05-31 23:22:15 -05:00
|
53 | / while let Some(x) = option {
54 | | println!("{}", x);
55 | | break;
56 | | }
2017-05-31 23:22:15 -05:00
| |_____^
|
= note: `-D never-loop` implied by `-D warnings`
error: this loop never actually loops
--> $DIR/for_loop.rs:59:5
2017-05-31 23:22:15 -05:00
|
59 | / while let Ok(x) = result {
60 | | println!("{}", x);
61 | | break;
62 | | }
2017-05-31 23:22:15 -05:00
| |_____^
error: the loop variable `i` is only used to index `vec`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:86:14
|
2018-01-28 22:18:11 -06:00
86 | for i in 0..vec.len() {
| ^^^^^^^^^^^^
|
= note: `-D needless-range-loop` implied by `-D warnings`
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
86 | for <item> in &vec {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is only used to index `vec`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:95:14
|
2018-01-28 22:18:11 -06:00
95 | for i in 0..vec.len() {
| ^^^^^^^^^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
95 | for <item> in &vec {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `j` is only used to index `STATIC`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:100:14
|
2018-01-28 22:18:11 -06:00
100 | for j in 0..4 {
| ^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
100 | for <item> in STATIC.iter().take(4) {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `j` is only used to index `CONST`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:104:14
|
2018-01-28 22:18:11 -06:00
104 | for j in 0..4 {
| ^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
104 | for <item> in CONST.iter().take(4) {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is used to index `vec`
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:108:14
|
2018-01-28 22:18:11 -06:00
108 | for i in 0..vec.len() {
| ^^^^^^^^^^^^
help: consider using an iterator
|
108 | for (i, <item>) in vec.iter().enumerate() {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is only used to index `vec2`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:116:14
|
2018-01-28 22:18:11 -06:00
116 | for i in 0..vec.len() {
| ^^^^^^^^^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
116 | for <item> in vec2.iter().take(vec.len()) {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is only used to index `vec`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:120:14
|
2018-01-28 22:18:11 -06:00
120 | for i in 5..vec.len() {
| ^^^^^^^^^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
120 | for <item> in vec.iter().skip(5) {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is only used to index `vec`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:124:14
|
2018-01-28 22:18:11 -06:00
124 | for i in 0..MAX_LEN {
| ^^^^^^^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
124 | for <item> in vec.iter().take(MAX_LEN) {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is only used to index `vec`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:128:14
|
2018-01-28 22:18:11 -06:00
128 | for i in 0..=MAX_LEN {
| ^^^^^^^^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
128 | for <item> in vec.iter().take(MAX_LEN + 1) {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is only used to index `vec`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:132:14
|
2018-01-28 22:18:11 -06:00
132 | for i in 5..10 {
| ^^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
132 | for <item> in vec.iter().take(10).skip(5) {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is only used to index `vec`.
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:136:14
|
2018-01-28 22:18:11 -06:00
136 | for i in 5..=10 {
| ^^^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
136 | for <item> in vec.iter().take(10 + 1).skip(5) {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is used to index `vec`
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:140:14
|
2018-01-28 22:18:11 -06:00
140 | for i in 5..vec.len() {
| ^^^^^^^^^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
140 | for (i, <item>) in vec.iter().enumerate().skip(5) {
2017-11-10 01:58:54 -06:00
|
error: the loop variable `i` is used to index `vec`
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:144:14
|
2018-01-28 22:18:11 -06:00
144 | for i in 5..10 {
| ^^^^^
help: consider using an iterator
2017-07-10 08:29:29 -05:00
|
144 | for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
2017-11-10 01:58:54 -06:00
|
error: this range is empty so this for loop will never run
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:148:14
|
2018-01-28 22:18:11 -06:00
148 | for i in 10..0 {
| ^^^^^
|
= note: `-D reverse-range-loop` implied by `-D warnings`
help: consider using the following if you are attempting to iterate over this range in reverse
2017-07-10 08:29:29 -05:00
|
148 | for i in (0..10).rev() {
2017-07-10 08:29:29 -05:00
| ^^^^^^^^^^^^^
error: this range is empty so this for loop will never run
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:152:14
|
2018-01-28 22:18:11 -06:00
152 | for i in 10..=0 {
| ^^^^^^
help: consider using the following if you are attempting to iterate over this range in reverse
2017-07-10 08:29:29 -05:00
|
152 | for i in (0...10).rev() {
2017-07-10 08:29:29 -05:00
| ^^^^^^^^^^^^^^
error: this range is empty so this for loop will never run
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:156:14
|
2018-01-28 22:18:11 -06:00
156 | for i in MAX_LEN..0 {
| ^^^^^^^^^^
help: consider using the following if you are attempting to iterate over this range in reverse
2017-07-10 08:29:29 -05:00
|
156 | for i in (0..MAX_LEN).rev() {
2017-07-10 08:29:29 -05:00
| ^^^^^^^^^^^^^^^^^^
error: this range is empty so this for loop will never run
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:160:14
|
2018-01-28 22:18:11 -06:00
160 | for i in 5..5 {
| ^^^^
error: this range is empty so this for loop will never run
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:185:14
|
2018-01-28 22:18:11 -06:00
185 | for i in 10..5 + 4 {
| ^^^^^^^^^
help: consider using the following if you are attempting to iterate over this range in reverse
2017-07-10 08:29:29 -05:00
|
185 | for i in (5 + 4..10).rev() {
| ^^^^^^^^^^^^^^^^^
error: this range is empty so this for loop will never run
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:189:14
|
2018-01-28 22:18:11 -06:00
189 | for i in (5 + 2)..(3 - 1) {
| ^^^^^^^^^^^^^^^^
help: consider using the following if you are attempting to iterate over this range in reverse
2017-07-10 08:29:29 -05:00
|
189 | for i in ((3 - 1)..(5 + 2)).rev() {
| ^^^^^^^^^^^^^^^^^^^^^^^^
error: this range is empty so this for loop will never run
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:193:14
|
2018-01-28 22:18:11 -06:00
193 | for i in (5 + 2)..(8 - 1) {
| ^^^^^^^^^^^^^^^^
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:215:15
|
215 | for _v in vec.iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^^ help: to write this more concisely, try: `&vec`
|
= note: `-D explicit-iter-loop` implied by `-D warnings`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:217:15
|
217 | for _v in vec.iter_mut() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&mut vec`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over containers instead of using explicit iteration methods`
--> $DIR/for_loop.rs:220:15
|
220 | for _v in out_vec.into_iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `out_vec`
|
= note: `-D explicit-into-iter-loop` implied by `-D warnings`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:223:15
|
223 | for _v in array.into_iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&array`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:228:15
2017-02-21 05:13:44 -06:00
|
228 | for _v in [1, 2, 3].iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[1, 2, 3]`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:232:15
|
232 | for _v in [0; 32].iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^^^^^^ help: to write this more concisely, try: `&[0; 32]`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:237:15
|
237 | for _v in ll.iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^ help: to write this more concisely, try: `&ll`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:240:15
|
240 | for _v in vd.iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^ help: to write this more concisely, try: `&vd`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:243:15
|
243 | for _v in bh.iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^ help: to write this more concisely, try: `&bh`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:246:15
|
246 | for _v in hm.iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^ help: to write this more concisely, try: `&hm`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:249:15
|
249 | for _v in bt.iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^ help: to write this more concisely, try: `&bt`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:252:15
|
252 | for _v in hs.iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^ help: to write this more concisely, try: `&hs`
2017-02-21 05:13:44 -06:00
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:255:15
|
255 | for _v in bs.iter() {}
2017-07-21 03:40:23 -05:00
| ^^^^^^^^^ help: to write this more concisely, try: `&bs`
error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:257:15
|
257 | for _v in vec.iter().next() {}
2018-01-28 22:18:11 -06:00
| ^^^^^^^^^^^^^^^^^
error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator
--> $DIR/for_loop.rs:264:5
|
264 | vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: `-D unused-collect` implied by `-D warnings`
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:269:15
|
2018-01-28 22:18:11 -06:00
269 | for _v in &vec {
| ^^^^
|
= note: `-D explicit-counter-loop` implied by `-D warnings`
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:275:15
|
2018-01-28 22:18:11 -06:00
275 | for _v in &vec {
| ^^^^
error: you seem to want to iterate on a map's values
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:385:19
|
2018-01-28 22:18:11 -06:00
385 | for (_, v) in &m {
| ^^
|
= note: `-D for-kv-map` implied by `-D warnings`
help: use the corresponding method
2017-07-10 08:29:29 -05:00
|
385 | for v in m.values() {
2017-11-10 01:58:54 -06:00
|
error: you seem to want to iterate on a map's values
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:390:19
|
390 | for (_, v) in &*m {
| ^^^
help: use the corresponding method
2017-07-10 08:29:29 -05:00
|
390 | for v in (*m).values() {
2017-11-10 01:58:54 -06:00
|
error: you seem to want to iterate on a map's values
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:398:19
|
2018-01-28 22:18:11 -06:00
398 | for (_, v) in &mut m {
| ^^^^^^
help: use the corresponding method
2017-07-10 08:29:29 -05:00
|
398 | for v in m.values_mut() {
2017-11-10 01:58:54 -06:00
|
error: you seem to want to iterate on a map's values
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:403:19
|
2018-01-28 22:18:11 -06:00
403 | for (_, v) in &mut *m {
| ^^^^^^^
help: use the corresponding method
2017-07-10 08:29:29 -05:00
|
403 | for v in (*m).values_mut() {
2017-11-10 01:58:54 -06:00
|
error: you seem to want to iterate on a map's keys
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:409:24
|
2018-01-28 22:18:11 -06:00
409 | for (k, _value) in rm {
| ^^
help: use the corresponding method
2017-07-10 08:29:29 -05:00
|
409 | for k in rm.keys() {
2017-11-10 01:58:54 -06:00
|
2017-09-04 19:16:34 -05:00
error: it looks like you're manually copying between slices
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:462:14
2017-09-04 19:16:34 -05:00
|
2018-01-28 22:18:11 -06:00
462 | for i in 0..src.len() {
| ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])`
2017-09-04 19:16:34 -05:00
|
= note: `-D manual-memcpy` implied by `-D warnings`
error: it looks like you're manually copying between slices
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:467:14
|
2018-01-28 22:18:11 -06:00
467 | for i in 0..src.len() {
| ^^^^^^^^^^^^ help: try replacing the loop by: `dst[10..(src.len() + 10)].clone_from_slice(&src[..])`
2017-09-04 19:16:34 -05:00
error: it looks like you're manually copying between slices
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:472:14
|
2018-01-28 22:18:11 -06:00
472 | for i in 0..src.len() {
| ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[10..])`
2017-09-04 19:16:34 -05:00
error: it looks like you're manually copying between slices
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:477:14
|
2018-01-28 22:18:11 -06:00
477 | for i in 11..src.len() {
| ^^^^^^^^^^^^^ help: try replacing the loop by: `dst[11..src.len()].clone_from_slice(&src[(11 - 10)..(src.len() - 10)])`
2017-09-04 19:16:34 -05:00
error: it looks like you're manually copying between slices
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:482:14
|
2018-01-28 22:18:11 -06:00
482 | for i in 0..dst.len() {
| ^^^^^^^^^^^^ help: try replacing the loop by: `dst.clone_from_slice(&src[..dst.len()])`
2017-09-04 19:16:34 -05:00
error: it looks like you're manually copying between slices
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:495:14
|
2018-01-28 22:18:11 -06:00
495 | for i in 10..256 {
| ^^^^^^^
2017-09-04 19:16:34 -05:00
help: try replacing the loop by
|
2018-01-28 22:18:11 -06:00
495 | for i in dst[10..256].clone_from_slice(&src[(10 - 5)..(256 - 5)])
496 | dst2[(10 + 500)..(256 + 500)].clone_from_slice(&src[10..256]) {
2017-09-04 19:16:34 -05:00
|
error: it looks like you're manually copying between slices
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:507:14
2017-09-04 19:16:34 -05:00
|
2018-01-28 22:18:11 -06:00
507 | for i in 10..LOOP_OFFSET {
| ^^^^^^^^^^^^^^^ 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)])`
2017-09-04 19:16:34 -05:00
error: it looks like you're manually copying between slices
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:520:14
2017-09-04 19:16:34 -05:00
|
2018-01-28 22:18:11 -06:00
520 | for i in 0..src_vec.len() {
| ^^^^^^^^^^^^^^^^ help: try replacing the loop by: `dst_vec[..src_vec.len()].clone_from_slice(&src_vec[..])`
error: it looks like you're manually copying between slices
2018-01-28 22:18:11 -06:00
--> $DIR/for_loop.rs:547:14
|
2018-01-28 22:18:11 -06:00
547 | for i in 0..src.len() {
| ^^^^^^^^^^^^ help: try replacing the loop by: `dst[..src.len()].clone_from_slice(&src[..])`
2018-01-16 10:06:27 -06:00
error: aborting due to 59 previous errors