3 #![warn(clippy::needless_bool)]
8 clippy::if_same_then_else,
9 clippy::equatable_if_let,
10 clippy::needless_return,
11 clippy::self_named_constructors
16 macro_rules! bool_comparison_trigger {
17 ($($i:ident: $def:expr, $stb:expr );+ $(;)*) => (
21 $($i: (Cell<bool>, bool, bool)),+
26 pub fn trigger(&self, key: &str) -> bool {
28 if let stringify!($i) = key {
29 return self.$i.1 && self.$i.2 == $def;
93 }; // would also be questionable, but we don't catch this yet
101 needless_bool_condition();
104 fn bool_ret3(x: bool) -> bool {
112 fn bool_ret4(x: bool) -> bool {
120 fn bool_ret5(x: bool, y: bool) -> bool {
128 fn bool_ret6(x: bool, y: bool) -> bool {
136 fn needless_bool(x: bool) {
140 fn needless_bool2(x: bool) {
144 fn needless_bool3(x: bool) {
145 bool_comparison_trigger! {
146 test_one: false, false;
147 test_three: false, false;
148 test_two: true, true;
155 fn needless_bool_in_the_suggestion_wraps_the_predicate_of_if_else_statement_in_brackets() {
157 let returns_bool = || false;
161 } else if returns_bool() {
168 unsafe fn no(v: u8) -> u8 {
172 #[allow(clippy::unnecessary_operation)]
173 fn needless_bool_condition() -> bool {
174 if unsafe { no(4) } & 1 != 0 {
179 let _brackets_unneeded = if unsafe { no(4) } & 1 != 0 { true } else { false };
181 // parentheses are needed here
182 if unsafe { no(4) } & 1 != 0 { true } else { false }