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