]> git.lizzy.rs Git - rust.git/blob - tests/ui/needless_bool.rs
Adapt the *.stderr files of the ui-tests to the tool_lints
[rust.git] / tests / ui / needless_bool.rs
1 #![feature(tool_lints)]
2
3 #![warn(clippy::needless_bool)]
4
5 #[allow(clippy::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     if x { false } else { true };
13     if x && y { false } else { true };
14     if x { x } else { false }; // would also be questionable, but we don't catch this yet
15     bool_ret(x);
16     bool_ret2(x);
17     bool_ret3(x);
18     bool_ret5(x, x);
19     bool_ret4(x);
20     bool_ret6(x, x);
21 }
22
23 #[allow(clippy::if_same_then_else, clippy::needless_return)]
24 fn bool_ret(x: bool) -> bool {
25     if x { return true } else { return true };
26 }
27
28 #[allow(clippy::if_same_then_else, clippy::needless_return)]
29 fn bool_ret2(x: bool) -> bool {
30     if x { return false } else { return false };
31 }
32
33 #[allow(clippy::needless_return)]
34 fn bool_ret3(x: bool) -> bool {
35     if x { return true } else { return false };
36 }
37
38 #[allow(clippy::needless_return)]
39 fn bool_ret5(x: bool, y: bool) -> bool {
40     if x && y { return true } else { return false };
41 }
42
43 #[allow(clippy::needless_return)]
44 fn bool_ret4(x: bool) -> bool {
45     if x { return false } else { return true };
46 }
47
48 #[allow(clippy::needless_return)]
49 fn bool_ret6(x: bool, y: bool) -> bool {
50     if x && y { return false } else { return true };
51 }