rust/tests/ui/for_loop.stderr

642 lines
19 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:18:14
|
18 | for x in option {
| ^^^^^^
|
= note: #[deny(for_loop_over_option)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/for_loop.rs:10:8
|
10 | #[deny(clippy)]
| ^^^^^^
= 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.
--> $DIR/for_loop.rs:26:14
|
26 | for x in result {
| ^^^^^^
|
= note: #[deny(for_loop_over_result)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/for_loop.rs:10:8
|
10 | #[deny(clippy)]
| ^^^^^^
= 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.
--> $DIR/for_loop.rs:32:14
|
32 | for x in option.ok_or("x not found") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(for_loop_over_result)] implied by #[deny(clippy)]
= 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
--> $DIR/for_loop.rs:40:5
|
40 | for x in v.iter().next() {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
41 | |
42 | | println!("{}", x);
43 | | }
| |_____^ ...ending here
|
= note: #[deny(iter_next_loop)] implied by #[deny(clippy)]
note: lint level defined here
--> $DIR/for_loop.rs:10:8
|
10 | #[deny(clippy)]
| ^^^^^^
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:47:14
|
47 | for x in v.iter().next().and(Some(0)) {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(for_loop_over_option)] implied by #[deny(clippy)]
= 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:53:14
|
53 | for x in v.iter().next().ok_or("x not found") {
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= note: #[deny(for_loop_over_result)] implied by #[deny(clippy)]
= 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")`
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:99:5
|
99 | for i in 0..vec.len() {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
100 | |
101 | |
102 | |
103 | |
104 | | println!("{}", vec[i]);
105 | | }
| |_____^ ...ending here
|
note: lint level defined here
--> $DIR/for_loop.rs:90:8
|
90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^^
help: consider using an iterator
| for <item> in &vec {
warning: unused variable: `i`
--> $DIR/for_loop.rs:107:9
|
107 | for i in 0..vec.len() {
| ^
|
= note: #[warn(unused_variables)] on by default
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:113:5
|
113 | for i in 0..vec.len() { let _ = vec[i]; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider using an iterator
| for <item> in &vec { let _ = vec[i]; }
error: the loop variable `j` is only used to index `STATIC`.
--> $DIR/for_loop.rs:120:5
|
120 | for j in 0..4 {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
121 | |
122 | |
123 | |
124 | |
125 | | println!("{:?}", STATIC[j]);
126 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for <item> in STATIC.iter().take(4) {
error: the loop variable `j` is only used to index `CONST`.
--> $DIR/for_loop.rs:128:5
|
128 | for j in 0..4 {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
129 | |
130 | |
131 | |
132 | |
133 | | println!("{:?}", CONST[j]);
134 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for <item> in CONST.iter().take(4) {
error: the loop variable `i` is used to index `vec`
--> $DIR/for_loop.rs:136:5
|
136 | for i in 0..vec.len() {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
137 | |
138 | |
139 | |
140 | |
141 | | println!("{} {}", vec[i], i);
142 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for (i, <item>) in vec.iter().enumerate() {
error: the loop variable `i` is only used to index `vec2`.
--> $DIR/for_loop.rs:147:5
|
147 | for i in 0..vec.len() {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
148 | |
149 | |
150 | |
151 | |
152 | | println!("{}", vec2[i]);
153 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for <item> in vec2.iter().take(vec.len()) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:155:5
|
155 | for i in 5..vec.len() {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
156 | |
157 | |
158 | |
159 | |
160 | | println!("{}", vec[i]);
161 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for <item> in vec.iter().skip(5) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:163:5
|
163 | for i in 0..MAX_LEN {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
164 | |
165 | |
166 | |
167 | |
168 | | println!("{}", vec[i]);
169 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for <item> in vec.iter().take(MAX_LEN) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:171:5
|
171 | for i in 0...MAX_LEN {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
172 | |
173 | |
174 | |
175 | |
176 | | println!("{}", vec[i]);
177 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for <item> in vec.iter().take(MAX_LEN + 1) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:179:5
|
179 | for i in 5..10 {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
180 | |
181 | |
182 | |
183 | |
184 | | println!("{}", vec[i]);
185 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for <item> in vec.iter().take(10).skip(5) {
error: the loop variable `i` is only used to index `vec`.
--> $DIR/for_loop.rs:187:5
|
187 | for i in 5...10 {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
188 | |
189 | |
190 | |
191 | |
192 | | println!("{}", vec[i]);
193 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for <item> in vec.iter().take(10 + 1).skip(5) {
error: the loop variable `i` is used to index `vec`
--> $DIR/for_loop.rs:195:5
|
195 | for i in 5..vec.len() {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
196 | |
197 | |
198 | |
199 | |
200 | | println!("{} {}", vec[i], i);
201 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for (i, <item>) in vec.iter().enumerate().skip(5) {
error: the loop variable `i` is used to index `vec`
--> $DIR/for_loop.rs:203:5
|
203 | for i in 5..10 {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
204 | |
205 | |
206 | |
207 | |
208 | | println!("{} {}", vec[i], i);
209 | | }
| |_____^ ...ending here
|
help: consider using an iterator
| for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:211:5
|
211 | for i in 10..0 {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
212 | |
213 | |
214 | |
215 | | println!("{}", i);
216 | | }
| |_____^ ...ending here
|
note: lint level defined here
--> $DIR/for_loop.rs:90:90
|
90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^
help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (0..10).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:218:5
|
218 | for i in 10...0 {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
219 | |
220 | |
221 | |
222 | | println!("{}", i);
223 | | }
| |_____^ ...ending here
|
help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (0...10).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:225:5
|
2017-02-08 07:58:07 -06:00
225 | for i in MAX_LEN..0 {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
226 | |
227 | |
228 | | println!("{}", i);
229 | | }
| |_____^ ...ending here
|
help: consider using the following if you are attempting to iterate over this range in reverse
2017-02-08 07:58:07 -06:00
| for i in (0..MAX_LEN).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:231:5
|
2017-02-08 07:58:07 -06:00
231 | for i in 5..5 {
| _____^ starting here...
232 | | println!("{}", i);
233 | | }
| |_____^ ...ending here
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:252:5
|
252 | for i in 10..5+4 {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
253 | |
254 | |
255 | |
256 | | println!("{}", i);
257 | | }
| |_____^ ...ending here
|
help: consider using the following if you are attempting to iterate over this range in reverse
| for i in (5+4..10).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:259:5
|
259 | for i in (5+2)..(3-1) {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
260 | |
261 | |
262 | |
263 | | println!("{}", i);
264 | | }
| |_____^ ...ending here
|
help: consider using the following if you are attempting to iterate over this range in reverse
| for i in ((3-1)..(5+2)).rev() {
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:266:5
|
2017-02-08 07:58:07 -06:00
266 | for i in (5+2)..(8-1) {
| _____^ starting here...
267 | | println!("{}", i);
268 | | }
| |_____^ ...ending here
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:289:15
|
289 | for _v in vec.iter() { }
| ^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:90:29
|
90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &vec { }
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:294:15
|
294 | for _v in vec.iter_mut() { }
| ^^^^^^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &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:300:15
|
300 | for _v in out_vec.into_iter() { }
| ^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:90:49
|
90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^^^^^^
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in out_vec { }
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:306:15
|
2017-02-21 05:13:44 -06:00
306 | for _v in array.into_iter() {}
| ^^^^^^^^^^^^^^^^^
|
help: to write this more concisely, try
| for _v in &array {}
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:311:15
|
311 | for _v in [1, 2, 3].iter() { }
| ^^^^^^^^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &[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:318:15
|
2017-02-21 05:13:44 -06:00
318 | for _v in [0; 32].iter() {}
| ^^^^^^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &[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:326:15
|
2017-02-21 05:13:44 -06:00
326 | for _v in ll.iter() { }
| ^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &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:332:15
|
2017-02-21 05:13:44 -06:00
332 | for _v in vd.iter() { }
| ^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &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:338:15
|
2017-02-21 05:13:44 -06:00
338 | for _v in bh.iter() { }
| ^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &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:344:15
|
2017-02-21 05:13:44 -06:00
344 | for _v in hm.iter() { }
| ^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &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:350:15
|
2017-02-21 05:13:44 -06:00
350 | for _v in bt.iter() { }
| ^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &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:356:15
|
2017-02-21 05:13:44 -06:00
356 | for _v in hs.iter() { }
| ^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &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:362:15
|
2017-02-21 05:13:44 -06:00
362 | for _v in bs.iter() { }
| ^^^^^^^^^
|
2017-02-21 05:13:44 -06:00
help: to write this more concisely, try
| for _v in &bs { }
error: you are iterating over `Iterator::next()` which is an Option; this will compile but is probably not what you want
2017-02-21 05:13:44 -06:00
--> $DIR/for_loop.rs:368:5
|
2017-02-21 05:13:44 -06:00
368 | for _v in vec.iter().next() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:90:74
|
90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^
error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator
2017-02-21 05:13:44 -06:00
--> $DIR/for_loop.rs:375:5
|
2017-02-21 05:13:44 -06:00
375 | vec.iter().map(|x| out.push(x)).collect::<Vec<_>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:91:8
|
91 | #[deny(unused_collect)]
| ^^^^^^^^^^^^^^
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
2017-02-21 05:13:44 -06:00
--> $DIR/for_loop.rs:380:5
|
2017-02-21 05:13:44 -06:00
380 | for _v in &vec { _index += 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:90:110
|
90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^^^^
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
2017-02-21 05:13:44 -06:00
--> $DIR/for_loop.rs:384:5
|
2017-02-21 05:13:44 -06:00
384 | for _v in &vec { _index += 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you seem to want to iterate on a map's values
2017-02-21 05:13:44 -06:00
--> $DIR/for_loop.rs:444:5
|
2017-02-21 05:13:44 -06:00
444 | for (_, v) in &m {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
445 | |
2017-02-21 05:13:44 -06:00
446 | |
447 | |
448 | |
449 | | let _v = v;
450 | | }
| |_____^ ...ending here
|
note: lint level defined here
--> $DIR/for_loop.rs:90:133
|
90 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^
help: use the corresponding method
| for v in m.values() {
error: you seem to want to iterate on a map's values
2017-02-21 05:13:44 -06:00
--> $DIR/for_loop.rs:453:5
|
2017-02-21 05:13:44 -06:00
453 | for (_, v) in &*m {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
454 | |
2017-02-21 05:13:44 -06:00
455 | |
456 | |
457 | |
458 | | let _v = v;
459 | | // Here the `*` is not actually necesarry, but the test tests that we don't suggest
460 | | // `in *m.values()` as we used to
461 | | }
| |_____^ ...ending here
|
help: use the corresponding method
| for v in (*m).values() {
error: you seem to want to iterate on a map's values
2017-02-21 05:13:44 -06:00
--> $DIR/for_loop.rs:464:5
|
2017-02-21 05:13:44 -06:00
464 | for (_, v) in &mut m {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
465 | |
2017-02-21 05:13:44 -06:00
466 | |
467 | |
468 | |
469 | | let _v = v;
470 | | }
| |_____^ ...ending here
|
help: use the corresponding method
| for v in m.values_mut() {
error: you seem to want to iterate on a map's values
2017-02-21 05:13:44 -06:00
--> $DIR/for_loop.rs:473:5
|
2017-02-21 05:13:44 -06:00
473 | for (_, v) in &mut *m {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
474 | |
2017-02-21 05:13:44 -06:00
475 | |
476 | |
477 | |
478 | | let _v = v;
479 | | }
| |_____^ ...ending here
|
help: use the corresponding method
| for v in (*m).values_mut() {
error: you seem to want to iterate on a map's keys
2017-02-21 05:13:44 -06:00
--> $DIR/for_loop.rs:483:5
|
2017-02-21 05:13:44 -06:00
483 | for (k, _value) in rm {
| _____^ starting here...
2017-02-08 07:58:07 -06:00
484 | |
2017-02-21 05:13:44 -06:00
485 | |
486 | |
487 | |
488 | | let _k = k;
489 | | }
| |_____^ ...ending here
|
help: use the corresponding method
| for k in rm.keys() {
2017-02-21 05:13:44 -06:00
error: aborting due to 48 previous errors