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;
57 }; // would also be questionable, but we don't catch this yet
65 needless_bool_condition();
68 fn bool_ret3(x: bool) -> bool {
72 fn bool_ret4(x: bool) -> bool {
76 fn bool_ret5(x: bool, y: bool) -> bool {
80 fn bool_ret6(x: bool, y: bool) -> bool {
84 fn needless_bool(x: bool) {
88 fn needless_bool2(x: bool) {
92 fn needless_bool3(x: bool) {
93 bool_comparison_trigger! {
94 test_one: false, false;
95 test_three: false, false;
103 fn needless_bool_in_the_suggestion_wraps_the_predicate_of_if_else_statement_in_brackets() {
105 let returns_bool = || false;
109 } else { !returns_bool() };
112 unsafe fn no(v: u8) -> u8 {
116 #[allow(clippy::unnecessary_operation)]
117 fn needless_bool_condition() -> bool {
118 (unsafe { no(4) } & 1 != 0);
119 let _brackets_unneeded = unsafe { no(4) } & 1 != 0;
121 // parentheses are needed here
122 (unsafe { no(4) } & 1 != 0)