]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_continue.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / needless_continue.rs
1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
3 //
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.
9
10 macro_rules! zero {
11     ($x:expr) => {
12         $x == 0
13     };
14 }
15
16 macro_rules! nonzero {
17     ($x:expr) => {
18         !zero!($x)
19     };
20 }
21
22 #[warn(clippy::needless_continue)]
23 fn main() {
24     let mut i = 1;
25     while i < 10 {
26         i += 1;
27
28         if i % 2 == 0 && i % 3 == 0 {
29             println!("{}", i);
30             println!("{}", i + 1);
31             if i % 5 == 0 {
32                 println!("{}", i + 2);
33             }
34             let i = 0;
35             println!("bar {} ", i);
36         } else {
37             continue;
38         }
39
40         println!("bleh");
41         {
42             println!("blah");
43         }
44
45         // some comments that also should ideally be included in the
46         // output of the lint suggestion if possible.
47         if !(!(i == 2) || !(i == 5)) {
48             println!("lama");
49         }
50
51         if (zero!(i % 2) || nonzero!(i % 5)) && i % 3 != 0 {
52             continue;
53         } else {
54             println!("Blabber");
55             println!("Jabber");
56         }
57
58         println!("bleh");
59     }
60 }