mirror of
https://github.com/rust-lang/rust-clippy
synced 2024-11-10 23:24:24 +00:00
Rustfmt for_loop.rs and add false positive tests
This commit is contained in:
parent
e4524ac4de
commit
b32631794a
2 changed files with 483 additions and 267 deletions
|
@ -4,14 +4,14 @@
|
|||
use std::collections::*;
|
||||
use std::rc::Rc;
|
||||
|
||||
static STATIC: [usize; 4] = [ 0, 1, 8, 16 ];
|
||||
const CONST: [usize; 4] = [ 0, 1, 8, 16 ];
|
||||
static STATIC: [usize; 4] = [0, 1, 8, 16];
|
||||
const CONST: [usize; 4] = [0, 1, 8, 16];
|
||||
|
||||
#[warn(clippy)]
|
||||
fn for_loop_over_option_and_result() {
|
||||
let option = Some(1);
|
||||
let result = option.ok_or("x not found");
|
||||
let v = vec![0,1,2];
|
||||
let v = vec![0, 1, 2];
|
||||
|
||||
// check FOR_LOOP_OVER_OPTION lint
|
||||
for x in option {
|
||||
|
@ -27,7 +27,8 @@ fn for_loop_over_option_and_result() {
|
|||
println!("{}", x);
|
||||
}
|
||||
|
||||
// make sure LOOP_OVER_NEXT lint takes precedence when next() is the last call in the chain
|
||||
// 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);
|
||||
}
|
||||
|
@ -72,7 +73,8 @@ impl Unrelated {
|
|||
}
|
||||
}
|
||||
|
||||
#[warn(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop, explicit_counter_loop, for_kv_map)]
|
||||
#[warn(needless_range_loop, explicit_iter_loop, explicit_into_iter_loop, iter_next_loop, reverse_range_loop,
|
||||
explicit_counter_loop, for_kv_map)]
|
||||
#[warn(unused_collect)]
|
||||
#[allow(linkedlist, shadow_unrelated, unnecessary_mut_passed, cyclomatic_complexity, similar_names)]
|
||||
#[allow(many_single_char_names, unused_variables)]
|
||||
|
@ -90,7 +92,9 @@ fn main() {
|
|||
println!("{}", vec[i]); // ok, not the `i` of the for-loop
|
||||
}
|
||||
|
||||
for i in 0..vec.len() { let _ = vec[i]; }
|
||||
for i in 0..vec.len() {
|
||||
let _ = vec[i];
|
||||
}
|
||||
|
||||
// ICE #746
|
||||
for j in 0..4 {
|
||||
|
@ -104,7 +108,8 @@ fn main() {
|
|||
for i in 0..vec.len() {
|
||||
println!("{} {}", vec[i], i);
|
||||
}
|
||||
for i in 0..vec.len() { // not an error, indexing more than one variable
|
||||
for i in 0..vec.len() {
|
||||
// not an error, indexing more than one variable
|
||||
println!("{} {}", vec[i], vec2[i]);
|
||||
}
|
||||
|
||||
|
@ -156,97 +161,104 @@ fn main() {
|
|||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in 5...5 { // not an error, this is the range with only one element “5”
|
||||
for i in 5...5 {
|
||||
// not an error, this is the range with only one element “5”
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in 0..10 { // not an error, the start index is less than the end index
|
||||
for i in 0..10 {
|
||||
// not an error, the start index is less than the end index
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in -10..0 { // not an error
|
||||
for i in -10..0 {
|
||||
// not an error
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in (10..0).map(|x| x * 2) { // not an error, it can't be known what arbitrary methods do to a range
|
||||
for i in (10..0).map(|x| x * 2) {
|
||||
// not an error, it can't be known what arbitrary methods do to a range
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
// testing that the empty range lint folds constants
|
||||
for i in 10..5+4 {
|
||||
for i in 10..5 + 4 {
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in (5+2)..(3-1) {
|
||||
for i in (5 + 2)..(3 - 1) {
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in (5+2)..(8-1) {
|
||||
for i in (5 + 2)..(8 - 1) {
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
for i in (2*2)..(2*3) { // no error, 4..6 is fine
|
||||
for i in (2 * 2)..(2 * 3) {
|
||||
// no error, 4..6 is fine
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
let x = 42;
|
||||
for i in x..10 { // no error, not constant-foldable
|
||||
for i in x..10 {
|
||||
// no error, not constant-foldable
|
||||
println!("{}", i);
|
||||
}
|
||||
|
||||
// See #601
|
||||
for i in 0..10 { // no error, id_col does not exist outside the loop
|
||||
for i in 0..10 {
|
||||
// no error, id_col does not exist outside the loop
|
||||
let mut id_col = vec![0f64; 10];
|
||||
id_col[i] = 1f64;
|
||||
}
|
||||
|
||||
for _v in vec.iter() { }
|
||||
for _v in vec.iter() {}
|
||||
|
||||
for _v in vec.iter_mut() { }
|
||||
for _v in vec.iter_mut() {}
|
||||
|
||||
let out_vec = vec![1,2,3];
|
||||
for _v in out_vec.into_iter() { }
|
||||
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() {}
|
||||
|
||||
for _v in &vec { } // these are fine
|
||||
for _v in &mut vec { } // these are fine
|
||||
for _v in &vec {} // these are fine
|
||||
for _v in &mut vec {} // these are fine
|
||||
|
||||
for _v in [1, 2, 3].iter() { }
|
||||
for _v in [1, 2, 3].iter() {}
|
||||
|
||||
for _v in (&mut [1, 2, 3]).iter() { } // no error
|
||||
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() { }
|
||||
for _v in ll.iter() {}
|
||||
|
||||
let vd: VecDeque<()> = VecDeque::new();
|
||||
for _v in vd.iter() { }
|
||||
for _v in vd.iter() {}
|
||||
|
||||
let bh: BinaryHeap<()> = BinaryHeap::new();
|
||||
for _v in bh.iter() { }
|
||||
for _v in bh.iter() {}
|
||||
|
||||
let hm: HashMap<(), ()> = HashMap::new();
|
||||
for _v in hm.iter() { }
|
||||
for _v in hm.iter() {}
|
||||
|
||||
let bt: BTreeMap<(), ()> = BTreeMap::new();
|
||||
for _v in bt.iter() { }
|
||||
for _v in bt.iter() {}
|
||||
|
||||
let hs: HashSet<()> = HashSet::new();
|
||||
for _v in hs.iter() { }
|
||||
for _v in hs.iter() {}
|
||||
|
||||
let bs: BTreeSet<()> = BTreeSet::new();
|
||||
for _v in bs.iter() { }
|
||||
for _v in bs.iter() {}
|
||||
|
||||
for _v in vec.iter().next() { }
|
||||
for _v in vec.iter().next() {}
|
||||
|
||||
let u = Unrelated(vec![]);
|
||||
for _v in u.next() { } // no error
|
||||
for _v in u.iter() { } // no error
|
||||
for _v in u.next() {} // no error
|
||||
for _v in u.iter() {} // no error
|
||||
|
||||
let mut out = vec![];
|
||||
vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>();
|
||||
|
@ -254,82 +266,135 @@ fn main() {
|
|||
|
||||
// Loop with explicit counter variable
|
||||
let mut _index = 0;
|
||||
for _v in &vec { _index += 1 }
|
||||
for _v in &vec {
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 1;
|
||||
_index = 0;
|
||||
for _v in &vec { _index += 1 }
|
||||
for _v in &vec {
|
||||
_index += 1
|
||||
}
|
||||
|
||||
// Potential false positives
|
||||
let mut _index = 0;
|
||||
_index = 1;
|
||||
for _v in &vec { _index += 1 }
|
||||
for _v in &vec {
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
_index += 1;
|
||||
for _v in &vec { _index += 1 }
|
||||
for _v in &vec {
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
if true { _index = 1 }
|
||||
for _v in &vec { _index += 1 }
|
||||
if true {
|
||||
_index = 1
|
||||
}
|
||||
for _v in &vec {
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
let mut _index = 1;
|
||||
for _v in &vec { _index += 1 }
|
||||
for _v in &vec {
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
for _v in &vec { _index += 1; _index += 1 }
|
||||
for _v in &vec {
|
||||
_index += 1;
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
for _v in &vec { _index *= 2; _index += 1 }
|
||||
for _v in &vec {
|
||||
_index *= 2;
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
for _v in &vec { _index = 1; _index += 1 }
|
||||
for _v in &vec {
|
||||
_index = 1;
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
|
||||
for _v in &vec { let mut _index = 0; _index += 1 }
|
||||
for _v in &vec {
|
||||
let mut _index = 0;
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
for _v in &vec { _index += 1; _index = 0; }
|
||||
for _v in &vec {
|
||||
_index += 1;
|
||||
_index = 0;
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
for _v in &vec { for _x in 0..1 { _index += 1; }; _index += 1 }
|
||||
for _v in &vec {
|
||||
for _x in 0..1 {
|
||||
_index += 1;
|
||||
}
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
for x in &vec { if *x == 1 { _index += 1 } }
|
||||
for x in &vec {
|
||||
if *x == 1 {
|
||||
_index += 1
|
||||
}
|
||||
}
|
||||
|
||||
let mut _index = 0;
|
||||
if true { _index = 1 };
|
||||
for _v in &vec { _index += 1 }
|
||||
if true {
|
||||
_index = 1
|
||||
};
|
||||
for _v in &vec {
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut _index = 1;
|
||||
if false { _index = 0 };
|
||||
for _v in &vec { _index += 1 }
|
||||
if false {
|
||||
_index = 0
|
||||
};
|
||||
for _v in &vec {
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut index = 0;
|
||||
{ let mut _x = &mut index; }
|
||||
for _v in &vec { _index += 1 }
|
||||
{
|
||||
let mut _x = &mut index;
|
||||
}
|
||||
for _v in &vec {
|
||||
_index += 1
|
||||
}
|
||||
|
||||
let mut index = 0;
|
||||
for _v in &vec { index += 1 }
|
||||
for _v in &vec {
|
||||
index += 1
|
||||
}
|
||||
println!("index: {}", index);
|
||||
|
||||
for_loop_over_option_and_result();
|
||||
|
||||
let m : HashMap<u64, u64> = HashMap::new();
|
||||
let m: HashMap<u64, u64> = HashMap::new();
|
||||
for (_, v) in &m {
|
||||
let _v = v;
|
||||
}
|
||||
|
||||
let m : Rc<HashMap<u64, u64>> = Rc::new(HashMap::new());
|
||||
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
|
||||
// Here the `*` is not actually necesarry, but the test tests that we don't
|
||||
// suggest
|
||||
// `in *m.values()` as we used to
|
||||
}
|
||||
|
||||
let mut m : HashMap<u64, u64> = HashMap::new();
|
||||
let mut m: HashMap<u64, u64> = HashMap::new();
|
||||
for (_, v) in &mut m {
|
||||
let _v = v;
|
||||
}
|
||||
|
@ -339,7 +404,7 @@ fn main() {
|
|||
let _v = v;
|
||||
}
|
||||
|
||||
let m : HashMap<u64, u64> = HashMap::new();
|
||||
let m: HashMap<u64, u64> = HashMap::new();
|
||||
let rm = &m;
|
||||
for (k, _value) in rm {
|
||||
let _k = k;
|
||||
|
@ -347,8 +412,12 @@ fn main() {
|
|||
|
||||
test_for_kv_map();
|
||||
|
||||
fn f<T>(_: &T, _: &T) -> bool { unimplemented!() }
|
||||
fn g<T>(_: &mut [T], _: usize, _: usize) { unimplemented!() }
|
||||
fn f<T>(_: &T, _: &T) -> bool {
|
||||
unimplemented!()
|
||||
}
|
||||
fn g<T>(_: &mut [T], _: usize, _: usize) {
|
||||
unimplemented!()
|
||||
}
|
||||
for i in 1..vec.len() {
|
||||
if f(&vec[i - 1], &vec[i]) {
|
||||
g(&mut vec, i - 1, i);
|
||||
|
@ -362,7 +431,7 @@ fn main() {
|
|||
|
||||
#[allow(used_underscore_binding)]
|
||||
fn test_for_kv_map() {
|
||||
let m : HashMap<u64, u64> = HashMap::new();
|
||||
let m: HashMap<u64, u64> = HashMap::new();
|
||||
|
||||
// No error, _value is actually used
|
||||
for (k, _value) in &m {
|
||||
|
@ -372,7 +441,7 @@ fn test_for_kv_map() {
|
|||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {
|
||||
fn partition<T: PartialOrd + Send>(v: &mut [T]) -> usize {
|
||||
let pivot = v.len() - 1;
|
||||
let mut i = 0;
|
||||
for j in 0..pivot {
|
||||
|
@ -384,3 +453,91 @@ fn partition<T:PartialOrd+Send>(v: &mut [T]) -> usize {
|
|||
v.swap(i, pivot);
|
||||
i
|
||||
}
|
||||
|
||||
const LOOP_OFFSET: usize = 5000;
|
||||
|
||||
#[warn(needless_range_loop)]
|
||||
pub fn manual_copy(src: &[i32], dst: &mut [i32], dst2: &mut [i32]) {
|
||||
// plain manual memcpy
|
||||
for i in 0..src.len() {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
|
||||
// dst offset memcpy
|
||||
for i in 0..src.len() {
|
||||
dst[i + 10] = src[i];
|
||||
}
|
||||
|
||||
// src offset memcpy
|
||||
for i in 0..src.len() {
|
||||
dst[i] = src[i + 10];
|
||||
}
|
||||
|
||||
// src offset memcpy
|
||||
for i in 11..src.len() {
|
||||
dst[i] = src[i - 10];
|
||||
}
|
||||
|
||||
// overwrite entire dst
|
||||
for i in 0..dst.len() {
|
||||
dst[i] = src[i];
|
||||
}
|
||||
|
||||
// manual copy with branch - can't easily convert to memcpy!
|
||||
for i in 0..src.len() {
|
||||
dst[i] = src[i];
|
||||
if dst[i] > 5 {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
// multiple copies - suggest two memcpy statements
|
||||
for i in 10..256 {
|
||||
dst[i] = src[i - 5];
|
||||
dst2[i + 500] = src[i]
|
||||
}
|
||||
|
||||
// this is a reversal - the copy lint shouldn't be triggered
|
||||
for i in 10..LOOP_OFFSET {
|
||||
dst[i + LOOP_OFFSET] = src[LOOP_OFFSET - i];
|
||||
}
|
||||
|
||||
let some_var = 5;
|
||||
// Offset in variable
|
||||
for i in 10..LOOP_OFFSET {
|
||||
dst[i + LOOP_OFFSET] = src[i - some_var];
|
||||
}
|
||||
|
||||
// Non continuous copy - don't trigger lint
|
||||
for i in 0..10 {
|
||||
dst[i + i] = src[i];
|
||||
}
|
||||
|
||||
let src_vec = vec![1, 2, 3, 4, 5];
|
||||
let mut dst_vec = vec![0, 0, 0, 0, 0];
|
||||
|
||||
// make sure vectors are supported
|
||||
for i in 0..src_vec.len() {
|
||||
dst_vec[i] = src_vec[i];
|
||||
}
|
||||
|
||||
// lint should not trigger when either
|
||||
// source or destination type is not
|
||||
// slice-like, like DummyStruct
|
||||
struct DummyStruct(i32);
|
||||
|
||||
impl ::std::ops::Index<usize> for DummyStruct {
|
||||
type Output = i32;
|
||||
|
||||
fn index(&self, _: usize) -> &i32 {
|
||||
&self.0
|
||||
}
|
||||
}
|
||||
|
||||
let src = DummyStruct(5);
|
||||
let mut dst_vec = vec![0; 10];
|
||||
|
||||
for i in 0..10 {
|
||||
dst_vec[i] = src[i];
|
||||
}
|
||||
}
|
||||
|
|
|
@ -25,478 +25,537 @@ error: for loop over `option.ok_or("x not found")`, which is a `Result`. This is
|
|||
= 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:31:5
|
||||
--> $DIR/for_loop.rs:32:5
|
||||
|
|
||||
31 | / for x in v.iter().next() {
|
||||
32 | | println!("{}", x);
|
||||
33 | | }
|
||||
32 | / for x in v.iter().next() {
|
||||
33 | | println!("{}", x);
|
||||
34 | | }
|
||||
| |_____^
|
||||
|
|
||||
= 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:36:14
|
||||
--> $DIR/for_loop.rs:37:14
|
||||
|
|
||||
36 | for x in v.iter().next().and(Some(0)) {
|
||||
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:40:14
|
||||
--> $DIR/for_loop.rs:41:14
|
||||
|
|
||||
40 | for x in v.iter().next().ok_or("x not found") {
|
||||
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")`
|
||||
|
||||
error: this loop never actually loops
|
||||
--> $DIR/for_loop.rs:52:5
|
||||
--> $DIR/for_loop.rs:53:5
|
||||
|
|
||||
52 | / while let Some(x) = option {
|
||||
53 | | println!("{}", x);
|
||||
54 | | break;
|
||||
55 | | }
|
||||
53 | / while let Some(x) = option {
|
||||
54 | | println!("{}", x);
|
||||
55 | | break;
|
||||
56 | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: `-D never-loop` implied by `-D warnings`
|
||||
|
||||
error: this loop never actually loops
|
||||
--> $DIR/for_loop.rs:58:5
|
||||
--> $DIR/for_loop.rs:59:5
|
||||
|
|
||||
58 | / while let Ok(x) = result {
|
||||
59 | | println!("{}", x);
|
||||
60 | | break;
|
||||
61 | | }
|
||||
59 | / while let Ok(x) = result {
|
||||
60 | | println!("{}", x);
|
||||
61 | | break;
|
||||
62 | | }
|
||||
| |_____^
|
||||
|
||||
error: the loop variable `i` is only used to index `vec`.
|
||||
--> $DIR/for_loop.rs:84:5
|
||||
--> $DIR/for_loop.rs:86:5
|
||||
|
|
||||
84 | / for i in 0..vec.len() {
|
||||
85 | | println!("{}", vec[i]);
|
||||
86 | | }
|
||||
86 | / for i in 0..vec.len() {
|
||||
87 | | println!("{}", vec[i]);
|
||||
88 | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: `-D needless-range-loop` implied by `-D warnings`
|
||||
help: consider using an iterator
|
||||
|
|
||||
84 | for <item> in &vec {
|
||||
86 | for <item> in &vec {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `i` is only used to index `vec`.
|
||||
--> $DIR/for_loop.rs:93:5
|
||||
--> $DIR/for_loop.rs:95:5
|
||||
|
|
||||
93 | for i in 0..vec.len() { let _ = vec[i]; }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
93 | for <item> in &vec { let _ = vec[i]; }
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `j` is only used to index `STATIC`.
|
||||
--> $DIR/for_loop.rs:96:5
|
||||
|
|
||||
96 | / for j in 0..4 {
|
||||
97 | | println!("{:?}", STATIC[j]);
|
||||
98 | | }
|
||||
95 | / for i in 0..vec.len() {
|
||||
96 | | let _ = vec[i];
|
||||
97 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
96 | for <item> in STATIC.iter().take(4) {
|
||||
95 | for <item> in &vec {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `j` is only used to index `CONST`.
|
||||
error: the loop variable `j` is only used to index `STATIC`.
|
||||
--> $DIR/for_loop.rs:100:5
|
||||
|
|
||||
100 | / for j in 0..4 {
|
||||
101 | | println!("{:?}", CONST[j]);
|
||||
101 | | println!("{:?}", STATIC[j]);
|
||||
102 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
100 | for <item> in CONST.iter().take(4) {
|
||||
100 | for <item> in STATIC.iter().take(4) {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `i` is used to index `vec`
|
||||
error: the loop variable `j` is only used to index `CONST`.
|
||||
--> $DIR/for_loop.rs:104:5
|
||||
|
|
||||
104 | / for i in 0..vec.len() {
|
||||
105 | | println!("{} {}", vec[i], i);
|
||||
104 | / for j in 0..4 {
|
||||
105 | | println!("{:?}", CONST[j]);
|
||||
106 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
104 | for (i, <item>) in vec.iter().enumerate() {
|
||||
104 | for <item> in CONST.iter().take(4) {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `i` is used to index `vec`
|
||||
--> $DIR/for_loop.rs:108:5
|
||||
|
|
||||
108 | / for i in 0..vec.len() {
|
||||
109 | | println!("{} {}", vec[i], i);
|
||||
110 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
108 | for (i, <item>) in vec.iter().enumerate() {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: the loop variable `i` is only used to index `vec2`.
|
||||
--> $DIR/for_loop.rs:111:5
|
||||
--> $DIR/for_loop.rs:116:5
|
||||
|
|
||||
111 | / for i in 0..vec.len() {
|
||||
112 | | println!("{}", vec2[i]);
|
||||
113 | | }
|
||||
116 | / for i in 0..vec.len() {
|
||||
117 | | println!("{}", vec2[i]);
|
||||
118 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
111 | for <item> in vec2.iter().take(vec.len()) {
|
||||
116 | for <item> in vec2.iter().take(vec.len()) {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `i` is only used to index `vec`.
|
||||
--> $DIR/for_loop.rs:115:5
|
||||
--> $DIR/for_loop.rs:120:5
|
||||
|
|
||||
115 | / for i in 5..vec.len() {
|
||||
116 | | println!("{}", vec[i]);
|
||||
117 | | }
|
||||
120 | / for i in 5..vec.len() {
|
||||
121 | | println!("{}", vec[i]);
|
||||
122 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
115 | for <item> in vec.iter().skip(5) {
|
||||
120 | for <item> in vec.iter().skip(5) {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `i` is only used to index `vec`.
|
||||
--> $DIR/for_loop.rs:119:5
|
||||
--> $DIR/for_loop.rs:124:5
|
||||
|
|
||||
119 | / for i in 0..MAX_LEN {
|
||||
120 | | println!("{}", vec[i]);
|
||||
121 | | }
|
||||
124 | / for i in 0..MAX_LEN {
|
||||
125 | | println!("{}", vec[i]);
|
||||
126 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
119 | for <item> in vec.iter().take(MAX_LEN) {
|
||||
124 | for <item> in vec.iter().take(MAX_LEN) {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `i` is only used to index `vec`.
|
||||
--> $DIR/for_loop.rs:123:5
|
||||
--> $DIR/for_loop.rs:128:5
|
||||
|
|
||||
123 | / for i in 0...MAX_LEN {
|
||||
124 | | println!("{}", vec[i]);
|
||||
125 | | }
|
||||
128 | / for i in 0...MAX_LEN {
|
||||
129 | | println!("{}", vec[i]);
|
||||
130 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
123 | for <item> in vec.iter().take(MAX_LEN + 1) {
|
||||
128 | for <item> in vec.iter().take(MAX_LEN + 1) {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `i` is only used to index `vec`.
|
||||
--> $DIR/for_loop.rs:127:5
|
||||
--> $DIR/for_loop.rs:132:5
|
||||
|
|
||||
127 | / for i in 5..10 {
|
||||
128 | | println!("{}", vec[i]);
|
||||
129 | | }
|
||||
132 | / for i in 5..10 {
|
||||
133 | | println!("{}", vec[i]);
|
||||
134 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
127 | for <item> in vec.iter().take(10).skip(5) {
|
||||
132 | for <item> in vec.iter().take(10).skip(5) {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `i` is only used to index `vec`.
|
||||
--> $DIR/for_loop.rs:131:5
|
||||
--> $DIR/for_loop.rs:136:5
|
||||
|
|
||||
131 | / for i in 5...10 {
|
||||
132 | | println!("{}", vec[i]);
|
||||
133 | | }
|
||||
136 | / for i in 5...10 {
|
||||
137 | | println!("{}", vec[i]);
|
||||
138 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
131 | for <item> in vec.iter().take(10 + 1).skip(5) {
|
||||
136 | for <item> in vec.iter().take(10 + 1).skip(5) {
|
||||
| ^^^^^^
|
||||
|
||||
error: the loop variable `i` is used to index `vec`
|
||||
--> $DIR/for_loop.rs:135:5
|
||||
--> $DIR/for_loop.rs:140:5
|
||||
|
|
||||
135 | / for i in 5..vec.len() {
|
||||
136 | | println!("{} {}", vec[i], i);
|
||||
137 | | }
|
||||
140 | / for i in 5..vec.len() {
|
||||
141 | | println!("{} {}", vec[i], i);
|
||||
142 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
135 | for (i, <item>) in vec.iter().enumerate().skip(5) {
|
||||
140 | for (i, <item>) in vec.iter().enumerate().skip(5) {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: the loop variable `i` is used to index `vec`
|
||||
--> $DIR/for_loop.rs:139:5
|
||||
--> $DIR/for_loop.rs:144:5
|
||||
|
|
||||
139 | / for i in 5..10 {
|
||||
140 | | println!("{} {}", vec[i], i);
|
||||
141 | | }
|
||||
144 | / for i in 5..10 {
|
||||
145 | | println!("{} {}", vec[i], i);
|
||||
146 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
139 | for (i, <item>) in vec.iter().enumerate().take(10).skip(5) {
|
||||
144 | 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:143:5
|
||||
--> $DIR/for_loop.rs:148:5
|
||||
|
|
||||
143 | / for i in 10..0 {
|
||||
144 | | println!("{}", i);
|
||||
145 | | }
|
||||
148 | / for i in 10..0 {
|
||||
149 | | println!("{}", i);
|
||||
150 | | }
|
||||
| |_____^
|
||||
|
|
||||
= 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
|
||||
|
|
||||
143 | for i in (0..10).rev() {
|
||||
148 | for i in (0..10).rev() {
|
||||
| ^^^^^^^^^^^^^
|
||||
|
||||
error: this range is empty so this for loop will never run
|
||||
--> $DIR/for_loop.rs:147:5
|
||||
--> $DIR/for_loop.rs:152:5
|
||||
|
|
||||
147 | / for i in 10...0 {
|
||||
148 | | println!("{}", i);
|
||||
149 | | }
|
||||
152 | / for i in 10...0 {
|
||||
153 | | println!("{}", i);
|
||||
154 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using the following if you are attempting to iterate over this range in reverse
|
||||
|
|
||||
147 | for i in (0...10).rev() {
|
||||
152 | for i in (0...10).rev() {
|
||||
| ^^^^^^^^^^^^^^
|
||||
|
||||
error: this range is empty so this for loop will never run
|
||||
--> $DIR/for_loop.rs:151:5
|
||||
--> $DIR/for_loop.rs:156:5
|
||||
|
|
||||
151 | / for i in MAX_LEN..0 {
|
||||
152 | | println!("{}", i);
|
||||
153 | | }
|
||||
156 | / for i in MAX_LEN..0 {
|
||||
157 | | println!("{}", i);
|
||||
158 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using the following if you are attempting to iterate over this range in reverse
|
||||
|
|
||||
151 | for i in (0..MAX_LEN).rev() {
|
||||
156 | for i in (0..MAX_LEN).rev() {
|
||||
| ^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this range is empty so this for loop will never run
|
||||
--> $DIR/for_loop.rs:155:5
|
||||
--> $DIR/for_loop.rs:160:5
|
||||
|
|
||||
155 | / for i in 5..5 {
|
||||
156 | | println!("{}", i);
|
||||
157 | | }
|
||||
160 | / for i in 5..5 {
|
||||
161 | | println!("{}", i);
|
||||
162 | | }
|
||||
| |_____^
|
||||
|
||||
error: this range is empty so this for loop will never run
|
||||
--> $DIR/for_loop.rs:176:5
|
||||
--> $DIR/for_loop.rs:185:5
|
||||
|
|
||||
176 | / for i in 10..5+4 {
|
||||
177 | | println!("{}", i);
|
||||
178 | | }
|
||||
185 | / for i in 10..5 + 4 {
|
||||
186 | | println!("{}", i);
|
||||
187 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using the following if you are attempting to iterate over this range in reverse
|
||||
|
|
||||
176 | for i in (5+4..10).rev() {
|
||||
| ^^^^^^^^^^^^^^^
|
||||
185 | for i in (5 + 4..10).rev() {
|
||||
| ^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this range is empty so this for loop will never run
|
||||
--> $DIR/for_loop.rs:180:5
|
||||
--> $DIR/for_loop.rs:189:5
|
||||
|
|
||||
180 | / for i in (5+2)..(3-1) {
|
||||
181 | | println!("{}", i);
|
||||
182 | | }
|
||||
189 | / for i in (5 + 2)..(3 - 1) {
|
||||
190 | | println!("{}", i);
|
||||
191 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using the following if you are attempting to iterate over this range in reverse
|
||||
|
|
||||
180 | for i in ((3-1)..(5+2)).rev() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^
|
||||
189 | for i in ((3 - 1)..(5 + 2)).rev() {
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
error: this range is empty so this for loop will never run
|
||||
--> $DIR/for_loop.rs:184:5
|
||||
--> $DIR/for_loop.rs:193:5
|
||||
|
|
||||
184 | / for i in (5+2)..(8-1) {
|
||||
185 | | println!("{}", i);
|
||||
186 | | }
|
||||
193 | / for i in (5 + 2)..(8 - 1) {
|
||||
194 | | println!("{}", i);
|
||||
195 | | }
|
||||
| |_____^
|
||||
|
||||
error: it is more idiomatic to loop over references to containers instead of using explicit iteration methods
|
||||
--> $DIR/for_loop.rs:203:15
|
||||
--> $DIR/for_loop.rs:215:15
|
||||
|
|
||||
203 | for _v in vec.iter() { }
|
||||
215 | 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
|
||||
--> $DIR/for_loop.rs:205:15
|
||||
--> $DIR/for_loop.rs:217:15
|
||||
|
|
||||
205 | for _v in vec.iter_mut() { }
|
||||
217 | 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:208:15
|
||||
--> $DIR/for_loop.rs:220:15
|
||||
|
|
||||
208 | for _v in out_vec.into_iter() { }
|
||||
220 | 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
|
||||
--> $DIR/for_loop.rs:211:15
|
||||
--> $DIR/for_loop.rs:223:15
|
||||
|
|
||||
211 | for _v in array.into_iter() {}
|
||||
223 | 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: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
|
||||
--> $DIR/for_loop.rs:220:15
|
||||
|
|
||||
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
|
||||
--> $DIR/for_loop.rs:225:15
|
||||
|
|
||||
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
|
||||
--> $DIR/for_loop.rs:228:15
|
||||
|
|
||||
228 | for _v in vd.iter() { }
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&vd`
|
||||
228 | 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:231:15
|
||||
--> $DIR/for_loop.rs:232:15
|
||||
|
|
||||
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
|
||||
--> $DIR/for_loop.rs:234:15
|
||||
|
|
||||
234 | for _v in hm.iter() { }
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&hm`
|
||||
232 | 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:237:15
|
||||
|
|
||||
237 | for _v in bt.iter() { }
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&bt`
|
||||
237 | 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:240:15
|
||||
|
|
||||
240 | for _v in hs.iter() { }
|
||||
| ^^^^^^^^^ help: to write this more concisely, try: `&hs`
|
||||
240 | 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:243:15
|
||||
|
|
||||
243 | for _v in bs.iter() { }
|
||||
243 | 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:246:15
|
||||
|
|
||||
246 | 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:249:15
|
||||
|
|
||||
249 | 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:252:15
|
||||
|
|
||||
252 | 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:255:15
|
||||
|
|
||||
255 | 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:245:5
|
||||
--> $DIR/for_loop.rs:257:5
|
||||
|
|
||||
245 | for _v in vec.iter().next() { }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
257 | 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
|
||||
--> $DIR/for_loop.rs:252:5
|
||||
--> $DIR/for_loop.rs:264:5
|
||||
|
|
||||
252 | vec.iter().cloned().map(|x| out.push(x)).collect::<Vec<_>>();
|
||||
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
|
||||
--> $DIR/for_loop.rs:257:5
|
||||
--> $DIR/for_loop.rs:269:5
|
||||
|
|
||||
257 | for _v in &vec { _index += 1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
269 | / for _v in &vec {
|
||||
270 | | _index += 1
|
||||
271 | | }
|
||||
| |_____^
|
||||
|
|
||||
= 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
|
||||
--> $DIR/for_loop.rs:261:5
|
||||
--> $DIR/for_loop.rs:275:5
|
||||
|
|
||||
261 | for _v in &vec { _index += 1 }
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
275 | / for _v in &vec {
|
||||
276 | | _index += 1
|
||||
277 | | }
|
||||
| |_____^
|
||||
|
||||
error: you seem to want to iterate on a map's values
|
||||
--> $DIR/for_loop.rs:321:5
|
||||
--> $DIR/for_loop.rs:385:5
|
||||
|
|
||||
321 | / for (_, v) in &m {
|
||||
322 | | let _v = v;
|
||||
323 | | }
|
||||
385 | / for (_, v) in &m {
|
||||
386 | | let _v = v;
|
||||
387 | | }
|
||||
| |_____^
|
||||
|
|
||||
= note: `-D for-kv-map` implied by `-D warnings`
|
||||
help: use the corresponding method
|
||||
|
|
||||
321 | for v in m.values() {
|
||||
385 | for v in m.values() {
|
||||
| ^
|
||||
|
||||
error: you seem to want to iterate on a map's values
|
||||
--> $DIR/for_loop.rs:326:5
|
||||
--> $DIR/for_loop.rs:390:5
|
||||
|
|
||||
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 | | }
|
||||
390 | / for (_, v) in &*m {
|
||||
391 | | let _v = v;
|
||||
392 | | // Here the `*` is not actually necesarry, but the test tests that we don't
|
||||
393 | | // suggest
|
||||
394 | | // `in *m.values()` as we used to
|
||||
395 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: use the corresponding method
|
||||
|
|
||||
326 | for v in (*m).values() {
|
||||
390 | for v in (*m).values() {
|
||||
| ^
|
||||
|
||||
error: you seem to want to iterate on a map's values
|
||||
--> $DIR/for_loop.rs:333:5
|
||||
--> $DIR/for_loop.rs:398:5
|
||||
|
|
||||
333 | / for (_, v) in &mut m {
|
||||
334 | | let _v = v;
|
||||
335 | | }
|
||||
398 | / for (_, v) in &mut m {
|
||||
399 | | let _v = v;
|
||||
400 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: use the corresponding method
|
||||
|
|
||||
333 | for v in m.values_mut() {
|
||||
398 | for v in m.values_mut() {
|
||||
| ^
|
||||
|
||||
error: you seem to want to iterate on a map's values
|
||||
--> $DIR/for_loop.rs:338:5
|
||||
--> $DIR/for_loop.rs:403:5
|
||||
|
|
||||
338 | / for (_, v) in &mut *m {
|
||||
339 | | let _v = v;
|
||||
340 | | }
|
||||
403 | / for (_, v) in &mut *m {
|
||||
404 | | let _v = v;
|
||||
405 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: use the corresponding method
|
||||
|
|
||||
338 | for v in (*m).values_mut() {
|
||||
403 | for v in (*m).values_mut() {
|
||||
| ^
|
||||
|
||||
error: you seem to want to iterate on a map's keys
|
||||
--> $DIR/for_loop.rs:344:5
|
||||
--> $DIR/for_loop.rs:409:5
|
||||
|
|
||||
344 | / for (k, _value) in rm {
|
||||
345 | | let _k = k;
|
||||
346 | | }
|
||||
409 | / for (k, _value) in rm {
|
||||
410 | | let _k = k;
|
||||
411 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: use the corresponding method
|
||||
|
|
||||
344 | for k in rm.keys() {
|
||||
409 | for k in rm.keys() {
|
||||
| ^
|
||||
|
||||
error: aborting due to 50 previous errors
|
||||
error: the loop variable `i` is used to index `src`
|
||||
--> $DIR/for_loop.rs:467:5
|
||||
|
|
||||
467 | / for i in 0..src.len() {
|
||||
468 | | dst[i + 10] = src[i];
|
||||
469 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
467 | for (i, <item>) in src.iter().enumerate() {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: the loop variable `i` is used to index `dst`
|
||||
--> $DIR/for_loop.rs:472:5
|
||||
|
|
||||
472 | / for i in 0..src.len() {
|
||||
473 | | dst[i] = src[i + 10];
|
||||
474 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
472 | for (i, <item>) in dst.iter().enumerate().take(src.len()) {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: the loop variable `i` is used to index `dst`
|
||||
--> $DIR/for_loop.rs:477:5
|
||||
|
|
||||
477 | / for i in 11..src.len() {
|
||||
478 | | dst[i] = src[i - 10];
|
||||
479 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
477 | for (i, <item>) in dst.iter().enumerate().take(src.len()).skip(11) {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: the loop variable `i` is used to index `src`
|
||||
--> $DIR/for_loop.rs:512:5
|
||||
|
|
||||
512 | / for i in 0..10 {
|
||||
513 | | dst[i + i] = src[i];
|
||||
514 | | }
|
||||
| |_____^
|
||||
|
|
||||
help: consider using an iterator
|
||||
|
|
||||
512 | for (i, <item>) in src.iter().enumerate().take(10) {
|
||||
| ^^^^^^^^^^^
|
||||
|
||||
error: aborting due to 54 previous errors
|
||||
|
||||
|
|
Loading…
Reference in a new issue