clean tests/ui/for_loop.rs

Cleaning the empty lines for clarity.
This commit is contained in:
Luis de Bethencourt 2017-05-11 12:15:10 +01:00
parent faca269488
commit 6d2329f2cb
2 changed files with 184 additions and 404 deletions

View File

@ -14,45 +14,30 @@ fn for_loop_over_option_and_result() {
let v = vec![0,1,2];
// check FOR_LOOP_OVER_OPTION lint
for x in option {
println!("{}", x);
}
// check FOR_LOOP_OVER_RESULT lint
for x in result {
println!("{}", x);
}
for x in option.ok_or("x not found") {
println!("{}", x);
}
// make sure LOOP_OVER_NEXT lint takes precedence when next() is the last call in the chain
for x in v.iter().next() {
println!("{}", x);
}
// make sure we lint when next() is not the last call in the chain
for x in v.iter().next().and(Some(0)) {
println!("{}", x);
}
for x in v.iter().next().ok_or("x not found") {
println!("{}", x);
}
@ -97,47 +82,26 @@ fn main() {
let mut vec = vec![1, 2, 3, 4];
let vec2 = vec![1, 2, 3, 4];
for i in 0..vec.len() {
println!("{}", vec[i]);
}
for i in 0..vec.len() {
let i = 42; // make a different `i`
println!("{}", vec[i]); // ok, not the `i` of the for-loop
}
for i in 0..vec.len() { let _ = vec[i]; }
// ICE #746
for j in 0..4 {
println!("{:?}", STATIC[j]);
}
for j in 0..4 {
println!("{:?}", CONST[j]);
}
for i in 0..vec.len() {
println!("{} {}", vec[i], i);
}
for i in 0..vec.len() { // not an error, indexing more than one variable
@ -145,86 +109,46 @@ fn main() {
}
for i in 0..vec.len() {
println!("{}", vec2[i]);
}
for i in 5..vec.len() {
println!("{}", vec[i]);
}
for i in 0..MAX_LEN {
println!("{}", vec[i]);
}
for i in 0...MAX_LEN {
println!("{}", vec[i]);
}
for i in 5..10 {
println!("{}", vec[i]);
}
for i in 5...10 {
println!("{}", vec[i]);
}
for i in 5..vec.len() {
println!("{} {}", vec[i], i);
}
for i in 5..10 {
println!("{} {}", vec[i], i);
}
for i in 10..0 {
println!("{}", i);
}
for i in 10...0 {
println!("{}", i);
}
for i in MAX_LEN..0 {
println!("{}", i);
}
@ -250,16 +174,10 @@ fn main() {
// testing that the empty range lint folds constants
for i in 10..5+4 {
println!("{}", i);
}
for i in (5+2)..(3-1) {
println!("{}", i);
}
@ -288,20 +206,11 @@ fn main() {
for _v in vec.iter() { }
for _v in vec.iter_mut() { }
let out_vec = vec![1,2,3];
for _v in out_vec.into_iter() { }
let array = [1, 2, 3];
for _v in array.into_iter() {}
@ -310,61 +219,33 @@ fn main() {
for _v in [1, 2, 3].iter() { }
for _v in (&mut [1, 2, 3]).iter() { } // no error
for _v in [0; 32].iter() {}
for _v in [0; 33].iter() {} // no error
let ll: LinkedList<()> = LinkedList::new();
for _v in ll.iter() { }
let vd: VecDeque<()> = VecDeque::new();
for _v in vd.iter() { }
let bh: BinaryHeap<()> = BinaryHeap::new();
for _v in bh.iter() { }
let hm: HashMap<(), ()> = HashMap::new();
for _v in hm.iter() { }
let bt: BTreeMap<(), ()> = BTreeMap::new();
for _v in bt.iter() { }
let hs: HashSet<()> = HashSet::new();
for _v in hs.iter() { }
let bs: BTreeSet<()> = BTreeSet::new();
for _v in bs.iter() { }
for _v in vec.iter().next() { }
let u = Unrelated(vec![]);
@ -442,19 +323,11 @@ fn main() {
let m : HashMap<u64, u64> = HashMap::new();
for (_, v) in &m {
let _v = v;
}
let m : Rc<HashMap<u64, u64>> = Rc::new(HashMap::new());
for (_, v) in &*m {
let _v = v;
// Here the `*` is not actually necesarry, but the test tests that we don't suggest
// `in *m.values()` as we used to
@ -462,29 +335,17 @@ fn main() {
let mut m : HashMap<u64, u64> = HashMap::new();
for (_, v) in &mut m {
let _v = v;
}
let m: &mut HashMap<u64, u64> = &mut HashMap::new();
for (_, v) in &mut *m {
let _v = v;
}
let m : HashMap<u64, u64> = HashMap::new();
let rm = &m;
for (k, _value) in rm {
let _k = k;
}

View File

@ -1,7 +1,7 @@
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
--> $DIR/for_loop.rs:17:14
|
18 | for x in option {
17 | for x in option {
| ^^^^^^
|
= note: #[deny(for_loop_over_option)] implied by #[deny(clippy)]
@ -13,9 +13,9 @@ note: lint level defined here
= 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
--> $DIR/for_loop.rs:22:14
|
26 | for x in result {
22 | for x in result {
| ^^^^^^
|
= note: #[deny(for_loop_over_result)] implied by #[deny(clippy)]
@ -27,21 +27,20 @@ note: lint level defined here
= 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
--> $DIR/for_loop.rs:26:14
|
32 | for x in option.ok_or("x not found") {
26 | 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
--> $DIR/for_loop.rs:31:5
|
40 | / for x in v.iter().next() {
41 | |
42 | | println!("{}", x);
43 | | }
31 | / for x in v.iter().next() {
32 | | println!("{}", x);
33 | | }
| |_____^
|
= note: #[deny(iter_next_loop)] implied by #[deny(clippy)]
@ -52,522 +51,442 @@ note: lint level defined here
| ^^^^^^
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
--> $DIR/for_loop.rs:36:14
|
47 | for x in v.iter().next().and(Some(0)) {
36 | 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
--> $DIR/for_loop.rs:40:14
|
53 | for x in v.iter().next().ok_or("x not found") {
40 | 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() {
100 | |
101 | |
102 | |
103 | |
104 | | println!("{}", vec[i]);
105 | | }
| |_____^
|
--> $DIR/for_loop.rs:84:5
|
84 | / for i in 0..vec.len() {
85 | | println!("{}", vec[i]);
86 | | }
| |_____^
|
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)]
| ^^^^^^^^^^^^^^^^^^^
--> $DIR/for_loop.rs:75:8
|
75 | #[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 {
| 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
--> $DIR/for_loop.rs:88:9
|
88 | 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]; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
--> $DIR/for_loop.rs:93:5
|
93 | for i in 0..vec.len() { let _ = vec[i]; }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
help: consider using an iterator
| for <item> in &vec { let _ = vec[i]; }
| 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 {
121 | |
122 | |
123 | |
124 | |
125 | | println!("{:?}", STATIC[j]);
126 | | }
| |_____^
|
--> $DIR/for_loop.rs:96:5
|
96 | / for j in 0..4 {
97 | | println!("{:?}", STATIC[j]);
98 | | }
| |_____^
|
help: consider using an iterator
| for <item> in STATIC.iter().take(4) {
| for <item> in STATIC.iter().take(4) {
error: the loop variable `j` is only used to index `CONST`.
--> $DIR/for_loop.rs:128:5
--> $DIR/for_loop.rs:100:5
|
128 | / for j in 0..4 {
129 | |
130 | |
131 | |
132 | |
133 | | println!("{:?}", CONST[j]);
134 | | }
100 | / for j in 0..4 {
101 | | println!("{:?}", CONST[j]);
102 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:104:5
|
136 | / for i in 0..vec.len() {
137 | |
138 | |
139 | |
140 | |
141 | | println!("{} {}", vec[i], i);
142 | | }
104 | / for i in 0..vec.len() {
105 | | println!("{} {}", vec[i], i);
106 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:111:5
|
147 | / for i in 0..vec.len() {
148 | |
149 | |
150 | |
151 | |
152 | | println!("{}", vec2[i]);
153 | | }
111 | / for i in 0..vec.len() {
112 | | println!("{}", vec2[i]);
113 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:115:5
|
155 | / for i in 5..vec.len() {
156 | |
157 | |
158 | |
159 | |
160 | | println!("{}", vec[i]);
161 | | }
115 | / for i in 5..vec.len() {
116 | | println!("{}", vec[i]);
117 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:119:5
|
163 | / for i in 0..MAX_LEN {
164 | |
165 | |
166 | |
167 | |
168 | | println!("{}", vec[i]);
169 | | }
119 | / for i in 0..MAX_LEN {
120 | | println!("{}", vec[i]);
121 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:123:5
|
171 | / for i in 0...MAX_LEN {
172 | |
173 | |
174 | |
175 | |
176 | | println!("{}", vec[i]);
177 | | }
123 | / for i in 0...MAX_LEN {
124 | | println!("{}", vec[i]);
125 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:127:5
|
179 | / for i in 5..10 {
180 | |
181 | |
182 | |
183 | |
184 | | println!("{}", vec[i]);
185 | | }
127 | / for i in 5..10 {
128 | | println!("{}", vec[i]);
129 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:131:5
|
187 | / for i in 5...10 {
188 | |
189 | |
190 | |
191 | |
192 | | println!("{}", vec[i]);
193 | | }
131 | / for i in 5...10 {
132 | | println!("{}", vec[i]);
133 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:135:5
|
195 | / for i in 5..vec.len() {
196 | |
197 | |
198 | |
199 | |
200 | | println!("{} {}", vec[i], i);
201 | | }
135 | / for i in 5..vec.len() {
136 | | println!("{} {}", vec[i], i);
137 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:139:5
|
203 | / for i in 5..10 {
204 | |
205 | |
206 | |
207 | |
208 | | println!("{} {}", vec[i], i);
209 | | }
139 | / for i in 5..10 {
140 | | println!("{} {}", vec[i], i);
141 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:143:5
|
211 | / for i in 10..0 {
212 | |
213 | |
214 | |
215 | | println!("{}", i);
216 | | }
143 | / for i in 10..0 {
144 | | println!("{}", i);
145 | | }
| |_____^
|
note: lint level defined here
--> $DIR/for_loop.rs:90:90
--> $DIR/for_loop.rs:75: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)]
75 | #[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
--> $DIR/for_loop.rs:147:5
|
218 | / for i in 10...0 {
219 | |
220 | |
221 | |
222 | | println!("{}", i);
223 | | }
147 | / for i in 10...0 {
148 | | println!("{}", i);
149 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:151:5
|
225 | / for i in MAX_LEN..0 {
226 | |
227 | |
228 | | println!("{}", i);
229 | | }
151 | / for i in MAX_LEN..0 {
152 | | println!("{}", i);
153 | | }
| |_____^
|
help: consider using the following if you are attempting to iterate over this range in reverse
| 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
--> $DIR/for_loop.rs:155:5
|
231 | / for i in 5..5 {
232 | | println!("{}", i);
233 | | }
155 | / for i in 5..5 {
156 | | println!("{}", i);
157 | | }
| |_____^
error: this range is empty so this for loop will never run
--> $DIR/for_loop.rs:252:5
--> $DIR/for_loop.rs:176:5
|
252 | / for i in 10..5+4 {
253 | |
254 | |
255 | |
256 | | println!("{}", i);
257 | | }
176 | / for i in 10..5+4 {
177 | | println!("{}", i);
178 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:180:5
|
259 | / for i in (5+2)..(3-1) {
260 | |
261 | |
262 | |
263 | | println!("{}", i);
264 | | }
180 | / for i in (5+2)..(3-1) {
181 | | println!("{}", i);
182 | | }
| |_____^
|
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
--> $DIR/for_loop.rs:184:5
|
266 | / for i in (5+2)..(8-1) {
267 | | println!("{}", i);
268 | | }
184 | / for i in (5+2)..(8-1) {
185 | | println!("{}", i);
186 | | }
| |_____^
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:289:15
--> $DIR/for_loop.rs:207:15
|
289 | for _v in vec.iter() { }
207 | for _v in vec.iter() { }
| ^^^^^^^^^^ help: to write this more concisely, try `&vec`
|
note: lint level defined here
--> $DIR/for_loop.rs:90:29
--> $DIR/for_loop.rs:75: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)]
75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:294:15
--> $DIR/for_loop.rs:209:15
|
294 | for _v in vec.iter_mut() { }
209 | for _v in vec.iter_mut() { }
| ^^^^^^^^^^^^^^ help: to write this more concisely, try `&mut vec`
error: it is more idiomatic to loop over containers instead of using explicit iteration methods`
--> $DIR/for_loop.rs:300:15
--> $DIR/for_loop.rs:212:15
|
300 | for _v in out_vec.into_iter() { }
212 | for _v in out_vec.into_iter() { }
| ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `out_vec`
|
note: lint level defined here
--> $DIR/for_loop.rs:90:49
--> $DIR/for_loop.rs:75: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)]
75 | #[deny(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
| ^^^^^^^^^^^^^^^^^^^^^^^
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:306:15
--> $DIR/for_loop.rs:215:15
|
306 | for _v in array.into_iter() {}
215 | for _v in array.into_iter() {}
| ^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&array`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:311:15
--> $DIR/for_loop.rs:220:15
|
311 | for _v in [1, 2, 3].iter() { }
220 | for _v in [1, 2, 3].iter() { }
| ^^^^^^^^^^^^^^^^ help: to write this more concisely, try `&[1, 2, 3]`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:318:15
--> $DIR/for_loop.rs:224:15
|
318 | for _v in [0; 32].iter() {}
224 | for _v in [0; 32].iter() {}
| ^^^^^^^^^^^^^^ help: to write this more concisely, try `&[0; 32]`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:326:15
--> $DIR/for_loop.rs:229:15
|
326 | for _v in ll.iter() { }
229 | for _v in ll.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&ll`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:332:15
--> $DIR/for_loop.rs:232:15
|
332 | for _v in vd.iter() { }
232 | for _v in vd.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&vd`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:338:15
--> $DIR/for_loop.rs:235:15
|
338 | for _v in bh.iter() { }
235 | for _v in bh.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&bh`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:344:15
--> $DIR/for_loop.rs:238:15
|
344 | for _v in hm.iter() { }
238 | for _v in hm.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&hm`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:350:15
--> $DIR/for_loop.rs:241:15
|
350 | for _v in bt.iter() { }
241 | for _v in bt.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&bt`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:356:15
--> $DIR/for_loop.rs:244:15
|
356 | for _v in hs.iter() { }
244 | for _v in hs.iter() { }
| ^^^^^^^^^ help: to write this more concisely, try `&hs`
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
--> $DIR/for_loop.rs:362:15
--> $DIR/for_loop.rs:247:15
|
362 | for _v in bs.iter() { }
247 | for _v in bs.iter() { }
| ^^^^^^^^^ 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
--> $DIR/for_loop.rs:368:5
--> $DIR/for_loop.rs:249:5
|
368 | for _v in vec.iter().next() { }
249 | for _v in vec.iter().next() { }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:90:74
--> $DIR/for_loop.rs:75: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)]
75 | #[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
--> $DIR/for_loop.rs:375:5
--> $DIR/for_loop.rs:256:5
|
375 | vec.iter().map(|x| out.push(x)).collect::<Vec<_>>();
256 | vec.iter().map(|x| out.push(x)).collect::<Vec<_>>();
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:91:8
--> $DIR/for_loop.rs:76:8
|
91 | #[deny(unused_collect)]
76 | #[deny(unused_collect)]
| ^^^^^^^^^^^^^^
error: the variable `_index` is used as a loop counter. Consider using `for (_index, item) in &vec.enumerate()` or similar iterators
--> $DIR/for_loop.rs:380:5
--> $DIR/for_loop.rs:261:5
|
380 | for _v in &vec { _index += 1 }
261 | for _v in &vec { _index += 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
note: lint level defined here
--> $DIR/for_loop.rs:90:110
--> $DIR/for_loop.rs:75: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)]
75 | #[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
--> $DIR/for_loop.rs:384:5
--> $DIR/for_loop.rs:265:5
|
384 | for _v in &vec { _index += 1 }
265 | for _v in &vec { _index += 1 }
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:444:5
--> $DIR/for_loop.rs:325:5
|
444 | / for (_, v) in &m {
445 | |
446 | |
447 | |
448 | |
449 | | let _v = v;
450 | | }
325 | / for (_, v) in &m {
326 | | let _v = v;
327 | | }
| |_____^
|
note: lint level defined here
--> $DIR/for_loop.rs:90:133
--> $DIR/for_loop.rs:75: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)]
75 | #[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
--> $DIR/for_loop.rs:453:5
--> $DIR/for_loop.rs:330:5
|
453 | / for (_, v) in &*m {
454 | |
455 | |
456 | |
... |
460 | | // `in *m.values()` as we used to
461 | | }
330 | / for (_, v) in &*m {
331 | | let _v = v;
332 | | // Here the `*` is not actually necesarry, but the test tests that we don't suggest
333 | | // `in *m.values()` as we used to
334 | | }
| |_____^
|
help: use the corresponding method
| for v in (*m).values() {
error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:464:5
--> $DIR/for_loop.rs:337:5
|
464 | / for (_, v) in &mut m {
465 | |
466 | |
467 | |
468 | |
469 | | let _v = v;
470 | | }
337 | / for (_, v) in &mut m {
338 | | let _v = v;
339 | | }
| |_____^
|
help: use the corresponding method
| for v in m.values_mut() {
error: you seem to want to iterate on a map's values
--> $DIR/for_loop.rs:473:5
--> $DIR/for_loop.rs:342:5
|
473 | / for (_, v) in &mut *m {
474 | |
475 | |
476 | |
477 | |
478 | | let _v = v;
479 | | }
342 | / for (_, v) in &mut *m {
343 | | let _v = v;
344 | | }
| |_____^
|
help: use the corresponding method
| for v in (*m).values_mut() {
error: you seem to want to iterate on a map's keys
--> $DIR/for_loop.rs:483:5
--> $DIR/for_loop.rs:348:5
|
483 | / for (k, _value) in rm {
484 | |
485 | |
486 | |
487 | |
488 | | let _k = k;
489 | | }
348 | / for (k, _value) in rm {
349 | | let _k = k;
350 | | }
| |_____^
|
help: use the corresponding method