1 // Copyright 2014-2018 The Rust Project Developers. See the COPYRIGHT
2 // file at the top-level directory of this distribution.
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.
13 #![warn(clippy::needless_bool)]
15 #[allow(clippy::if_same_then_else)]
19 if x { true } else { true };
20 if x { false } else { false };
21 if x { true } else { false };
22 if x { false } else { true };
23 if x && y { false } else { true };
24 if x { x } else { false }; // would also be questionable, but we don't catch this yet
33 #[allow(clippy::if_same_then_else, clippy::needless_return)]
34 fn bool_ret(x: bool) -> bool {
35 if x { return true } else { return true };
38 #[allow(clippy::if_same_then_else, clippy::needless_return)]
39 fn bool_ret2(x: bool) -> bool {
40 if x { return false } else { return false };
43 #[allow(clippy::needless_return)]
44 fn bool_ret3(x: bool) -> bool {
45 if x { return true } else { return false };
48 #[allow(clippy::needless_return)]
49 fn bool_ret5(x: bool, y: bool) -> bool {
50 if x && y { return true } else { return false };
53 #[allow(clippy::needless_return)]
54 fn bool_ret4(x: bool) -> bool {
55 if x { return false } else { return true };
58 #[allow(clippy::needless_return)]
59 fn bool_ret6(x: bool, y: bool) -> bool {
60 if x && y { return false } else { return true };