1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
4 // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
5 // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
6 // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
7 // option. This file may not be copied, modified, or distributed
8 // except according to those terms.
10 #![warn(clippy::explicit_counter_loop)]
13 let mut vec = vec![1, 2, 3, 4];
28 // should not trigger the lint because variable is used after the loop #473
29 let vec = vec![1, 2, 3];
34 println!("index: {}", index);
36 // should not trigger the lint because the count is conditional #1219
39 for ch in text.chars() {
44 println!("{}", count);
47 // should not trigger the lint because the count is conditional
50 for ch in text.chars() {
54 println!("{}", count);
57 // should trigger the lint because the count is not conditional
60 for ch in text.chars() {
65 println!("{}", count);
68 // should trigger the lint because the count is not conditional
71 for ch in text.chars() {
76 println!("{}", count);
79 // should not trigger the lint because the count is incremented multiple times
82 for ch in text.chars() {
87 println!("{}", count);
94 // should not trigger the lint because the count is incremented multiple times
96 let erasures = vec![];
98 while erasures.contains(&(i + skips)) {
101 println!("{}", skips);
104 // should not trigger the lint because the count is incremented multiple times
112 println!("{}", skips);
115 // should not trigger the lint because the count is incremented multiple times
121 println!("{}", skips);