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.
10 #![warn(clippy::needless_bool)]
14 macro_rules! bool_comparison_trigger {
15 ($($i:ident: $def:expr, $stb:expr );+ $(;)*) => (
19 $($i: (Cell<bool>, bool, bool)),+
24 pub fn trigger(&self, key: &str) -> bool {
26 if let stringify!($i) = key {
27 return self.$i.1 && self.$i.2 == $def;
36 #[allow(clippy::if_same_then_else)]
69 }; // would also be questionable, but we don't catch this yet
81 #[allow(clippy::if_same_then_else, clippy::needless_return)]
82 fn bool_ret(x: bool) -> bool {
90 #[allow(clippy::if_same_then_else, clippy::needless_return)]
91 fn bool_ret2(x: bool) -> bool {
99 #[allow(clippy::needless_return)]
100 fn bool_ret3(x: bool) -> bool {
108 #[allow(clippy::needless_return)]
109 fn bool_ret5(x: bool, y: bool) -> bool {
117 #[allow(clippy::needless_return)]
118 fn bool_ret4(x: bool) -> bool {
126 #[allow(clippy::needless_return)]
127 fn bool_ret6(x: bool, y: bool) -> bool {
135 fn needless_bool(x: bool) {
139 fn needless_bool2(x: bool) {
143 fn needless_bool3(x: bool) {
144 bool_comparison_trigger! {
145 test_one: false, false;
146 test_three: false, false;
147 test_two: true, true;