]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_bool.rs
Merge pull request #1520 from Manishearth/rustup
[rust.git] / tests / ui / needless_bool.rs
1 #![feature(plugin)]
2 #![plugin(clippy)]
3 #![deny(needless_bool)]
4
5 #[allow(if_same_then_else)]
6 fn main() {
7     let x = true;
8     let y = false;
9     if x { true } else { true };
10     if x { false } else { false };
11     if x { true } else { false };
12
13
14
15     if x { false } else { true };
16
17
18
19     if x && y { false } else { true };
20
21
22
23     if x { x } else { false }; // would also be questionable, but we don't catch this yet
24     bool_ret(x);
25     bool_ret2(x);
26     bool_ret3(x);
27     bool_ret5(x, x);
28     bool_ret4(x);
29     bool_ret6(x, x);
30 }
31
32 #[allow(if_same_then_else, needless_return)]
33 fn bool_ret(x: bool) -> bool {
34     if x { return true } else { return true };
35
36 }
37
38 #[allow(if_same_then_else, needless_return)]
39 fn bool_ret2(x: bool) -> bool {
40     if x { return false } else { return false };
41
42 }
43
44 #[allow(needless_return)]
45 fn bool_ret3(x: bool) -> bool {
46     if x { return true } else { return false };
47
48
49
50 }
51
52 #[allow(needless_return)]
53 fn bool_ret5(x: bool, y: bool) -> bool {
54     if x && y { return true } else { return false };
55
56
57
58 }
59
60 #[allow(needless_return)]
61 fn bool_ret4(x: bool) -> bool {
62     if x { return false } else { return true };
63
64
65
66 }
67
68 #[allow(needless_return)]
69 fn bool_ret6(x: bool, y: bool) -> bool {
70     if x && y { return false } else { return true };
71
72
73
74 }