1 #![feature(adt_const_params)]
2 #![warn(clippy::same_functions_in_if_condition)]
3 // ifs_same_cond warning is different from `ifs_same_cond`.
4 // clippy::if_same_then_else, clippy::comparison_chain -- all empty blocks
5 #![allow(incomplete_features)]
7 clippy::comparison_chain,
8 clippy::if_same_then_else,
10 clippy::uninlined_format_args
13 fn function() -> bool {
17 fn fn_arg(_arg: u8) -> bool {
24 fn method(&self) -> bool {
27 fn method_arg(&self, _arg: u8) -> bool {
32 fn ifs_same_cond_fn() {
37 } else if function() {
38 //~ ERROR ifs same condition
43 //~ ERROR ifs same condition
47 } else if obj.method() {
48 //~ ERROR ifs same condition
51 if obj.method_arg(a) {
52 } else if obj.method_arg(a) {
53 //~ ERROR ifs same condition
57 if v.pop().is_none() {
58 //~ ERROR ifs same condition
59 } else if v.pop().is_none() {
63 //~ ERROR ifs same condition
64 } else if v.len() == 42 {
68 // ok, different conditions
69 } else if v.len() == 2 {
73 // ok, different arguments.
77 if obj.method_arg(0) {
78 // ok, different arguments.
79 } else if obj.method_arg(1) {
83 // ok, warning is on `ifs_same_cond` behalf.
89 // macro as condition (see #6168)
90 let os = if cfg!(target_os = "macos") {
92 } else if cfg!(target_os = "windows") {
99 #[derive(PartialEq, Eq)]
104 fn generic<const P: E>() -> bool {
110 if generic::<{ E::A }>() {
112 } else if generic::<{ E::B }>() {