From 85384afca37710a9b53800132374c51033f91fe5 Mon Sep 17 00:00:00 2001 From: uHOOCCOOHu Date: Wed, 5 Jul 2017 14:14:24 +0800 Subject: [PATCH] Remove tests using removed feature `step_by`. Update test outputs. --- clippy_tests/examples/for_loop.rs | 6 +- clippy_tests/examples/for_loop.stderr | 136 ++++++++++++-------------- clippy_tests/examples/range.rs | 13 +-- clippy_tests/examples/range.stderr | 46 +-------- 4 files changed, 69 insertions(+), 132 deletions(-) diff --git a/clippy_tests/examples/for_loop.rs b/clippy_tests/examples/for_loop.rs index 4770befe541..2f47b1b8022 100644 --- a/clippy_tests/examples/for_loop.rs +++ b/clippy_tests/examples/for_loop.rs @@ -1,4 +1,4 @@ -#![feature(plugin, step_by, inclusive_range_syntax)] +#![feature(plugin, inclusive_range_syntax)] #![plugin(clippy)] use std::collections::*; @@ -189,10 +189,6 @@ fn main() { println!("{}", i); } - for i in (10..8).step_by(-1) { - println!("{}", i); - } - let x = 42; for i in x..10 { // no error, not constant-foldable println!("{}", i); diff --git a/clippy_tests/examples/for_loop.stderr b/clippy_tests/examples/for_loop.stderr index a7ce0ec5f7f..e8819ae329e 100644 --- a/clippy_tests/examples/for_loop.stderr +++ b/clippy_tests/examples/for_loop.stderr @@ -292,130 +292,122 @@ error: this range is empty so this for loop will never run 186 | | } | |_____^ -error: use of deprecated item: replaced by `Iterator::step_by` - --> for_loop.rs:192:22 - | -192 | for i in (10..8).step_by(-1) { - | ^^^^^^^ - | - = note: `-D deprecated` implied by `-D warnings` - error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> for_loop.rs:207:15 + --> for_loop.rs:203:15 | -207 | for _v in vec.iter() { } +203 | for _v in vec.iter() { } | ^^^^^^^^^^ help: to write this more concisely, try `&vec` | = note: `-D explicit-iter-loop` implied by `-D warnings` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> for_loop.rs:209:15 + --> for_loop.rs:205:15 | -209 | for _v in vec.iter_mut() { } +205 | 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` - --> for_loop.rs:212:15 + --> for_loop.rs:208:15 | -212 | for _v in out_vec.into_iter() { } +208 | for _v in out_vec.into_iter() { } | ^^^^^^^^^^^^^^^^^^^ help: to write this more concisely, try `out_vec` | = note: `-D explicit-into-iter-loop` implied by `-D warnings` error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods - --> for_loop.rs:215:15 + --> for_loop.rs:211:15 | -215 | for _v in array.into_iter() {} +211 | 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 + --> for_loop.rs:216:15 + | +216 | 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 --> for_loop.rs:220:15 | -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 - --> for_loop.rs:224:15 - | -224 | for _v in [0; 32].iter() {} +220 | 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 - --> for_loop.rs:229:15 + --> for_loop.rs:225:15 | -229 | for _v in ll.iter() { } +225 | 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 - --> for_loop.rs:232:15 + --> for_loop.rs:228:15 | -232 | for _v in vd.iter() { } +228 | 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 - --> for_loop.rs:235:15 + --> for_loop.rs:231:15 | -235 | for _v in bh.iter() { } +231 | 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 - --> for_loop.rs:238:15 + --> for_loop.rs:234:15 | -238 | for _v in hm.iter() { } +234 | 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 - --> for_loop.rs:241:15 + --> for_loop.rs:237:15 | -241 | for _v in bt.iter() { } +237 | 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 - --> for_loop.rs:244:15 + --> for_loop.rs:240:15 | -244 | for _v in hs.iter() { } +240 | 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 - --> for_loop.rs:247:15 + --> for_loop.rs:243:15 | -247 | for _v in bs.iter() { } +243 | 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 - --> for_loop.rs:249:5 + --> for_loop.rs:245:5 | -249 | for _v in vec.iter().next() { } +245 | for _v in vec.iter().next() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you are collect()ing an iterator and throwing away the result. Consider using an explicit for loop to exhaust the iterator - --> for_loop.rs:256:5 + --> for_loop.rs:252:5 | -256 | vec.iter().map(|x| out.push(x)).collect::>(); +252 | vec.iter().map(|x| out.push(x)).collect::>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = 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 + --> for_loop.rs:257:5 + | +257 | for _v in &vec { _index += 1 } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = 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 --> for_loop.rs:261:5 | 261 | for _v in &vec { _index += 1 } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = 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 - --> for_loop.rs:265:5 - | -265 | for _v in &vec { _index += 1 } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: you seem to want to iterate on a map's values - --> for_loop.rs:325:5 + --> for_loop.rs:321:5 | -325 | / for (_, v) in &m { -326 | | let _v = v; -327 | | } +321 | / for (_, v) in &m { +322 | | let _v = v; +323 | | } | |_____^ | = note: `-D for-kv-map` implied by `-D warnings` @@ -423,52 +415,52 @@ help: use the corresponding method | for v in m.values() { error: you seem to want to iterate on a map's values - --> for_loop.rs:330:5 + --> for_loop.rs:326:5 | -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 | | } +326 | / for (_, v) in &*m { +327 | | let _v = v; +328 | | // Here the `*` is not actually necesarry, but the test tests that we don't suggest +329 | | // `in *m.values()` as we used to +330 | | } | |_____^ | help: use the corresponding method | for v in (*m).values() { error: you seem to want to iterate on a map's values - --> for_loop.rs:337:5 + --> for_loop.rs:333:5 | -337 | / for (_, v) in &mut m { -338 | | let _v = v; -339 | | } +333 | / for (_, v) in &mut m { +334 | | let _v = v; +335 | | } | |_____^ | help: use the corresponding method | for v in m.values_mut() { error: you seem to want to iterate on a map's values - --> for_loop.rs:342:5 + --> for_loop.rs:338:5 | -342 | / for (_, v) in &mut *m { -343 | | let _v = v; -344 | | } +338 | / for (_, v) in &mut *m { +339 | | let _v = v; +340 | | } | |_____^ | help: use the corresponding method | for v in (*m).values_mut() { error: you seem to want to iterate on a map's keys - --> for_loop.rs:348:5 + --> for_loop.rs:344:5 | -348 | / for (k, _value) in rm { -349 | | let _k = k; -350 | | } +344 | / for (k, _value) in rm { +345 | | let _k = k; +346 | | } | |_____^ | help: use the corresponding method | for k in rm.keys() { -error: aborting due to 52 previous errors +error: aborting due to 51 previous errors To learn more, run the command again with --verbose. diff --git a/clippy_tests/examples/range.rs b/clippy_tests/examples/range.rs index cb7504a9ecc..f6d07f31cf5 100644 --- a/clippy_tests/examples/range.rs +++ b/clippy_tests/examples/range.rs @@ -1,5 +1,4 @@ #![feature(iterator_step_by)] -#![feature(step_by)] #![feature(inclusive_range_syntax)] #![feature(plugin)] #![plugin(clippy)] @@ -11,15 +10,8 @@ impl NotARange { #[warn(iterator_step_by_zero, range_zip_with_len)] fn main() { - (0..1).step_by(0); // No warning for non-zero step - (0..1).step_by(1); - - (1..).step_by(0); - (1...2).step_by(0); - - let x = 0..1; - x.step_by(0); + let _ = (0..1).step_by(1); // No error, not a range. let y = NotARange; @@ -29,7 +21,4 @@ fn main() { let v2 = vec![4,5]; let _x = v1.iter().zip(0..v1.len()); let _y = v1.iter().zip(0..v2.len()); // No error - - // check const eval - let _ = v1.iter().step_by(2/3); } diff --git a/clippy_tests/examples/range.stderr b/clippy_tests/examples/range.stderr index 8b9643b3782..3bc5fd06c41 100644 --- a/clippy_tests/examples/range.stderr +++ b/clippy_tests/examples/range.stderr @@ -1,52 +1,12 @@ -error: use of deprecated item: replaced by `Iterator::step_by` - --> range.rs:14:12 - | -14 | (0..1).step_by(0); - | ^^^^^^^ - | - = note: `-D deprecated` implied by `-D warnings` - -error: use of deprecated item: replaced by `Iterator::step_by` - --> range.rs:16:12 - | -16 | (0..1).step_by(1); - | ^^^^^^^ - -error: use of deprecated item: replaced by `Iterator::step_by` - --> range.rs:18:11 - | -18 | (1..).step_by(0); - | ^^^^^^^ - -error: use of deprecated item: replaced by `Iterator::step_by` - --> range.rs:19:13 - | -19 | (1...2).step_by(0); - | ^^^^^^^ - -error: use of deprecated item: replaced by `Iterator::step_by` - --> range.rs:22:7 - | -22 | x.step_by(0); - | ^^^^^^^ - error: It is more idiomatic to use v1.iter().enumerate() - --> range.rs:30:14 + --> range.rs:22:14 | -30 | let _x = v1.iter().zip(0..v1.len()); +22 | let _x = v1.iter().zip(0..v1.len()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: `-D range-zip-with-len` implied by `-D warnings` -error: Iterator::step_by(0) will panic at runtime - --> range.rs:34:13 - | -34 | let _ = v1.iter().step_by(2/3); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: `-D iterator-step-by-zero` implied by `-D warnings` - -error: aborting due to 7 previous errors +error: aborting due to previous error To learn more, run the command again with --verbose.