]> git.lizzy.rs Git - rust.git/blob - tests/ui/else_if_without_else.rs
Auto merge of #3603 - xfix:random-state-lint, r=phansch
[rust.git] / tests / ui / else_if_without_else.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 #![warn(clippy::all)]
11 #![warn(clippy::else_if_without_else)]
12
13 fn bla1() -> bool {
14     unimplemented!()
15 }
16 fn bla2() -> bool {
17     unimplemented!()
18 }
19 fn bla3() -> bool {
20     unimplemented!()
21 }
22
23 fn main() {
24     if bla1() {
25         println!("if");
26     }
27
28     if bla1() {
29         println!("if");
30     } else {
31         println!("else");
32     }
33
34     if bla1() {
35         println!("if");
36     } else if bla2() {
37         println!("else if");
38     } else {
39         println!("else")
40     }
41
42     if bla1() {
43         println!("if");
44     } else if bla2() {
45         println!("else if 1");
46     } else if bla3() {
47         println!("else if 2");
48     } else {
49         println!("else")
50     }
51
52     if bla1() {
53         println!("if");
54     } else if bla2() {
55         //~ ERROR else if without else
56         println!("else if");
57     }
58
59     if bla1() {
60         println!("if");
61     } else if bla2() {
62         println!("else if 1");
63     } else if bla3() {
64         //~ ERROR else if without else
65         println!("else if 2");
66     }
67 }