1 #![feature(adt_const_params)]
2 #![allow(incomplete_features)]
3 #![warn(clippy::same_functions_in_if_condition)]
4 #![allow(clippy::ifs_same_cond)] // This warning is different from `ifs_same_cond`.
5 #![allow(clippy::if_same_then_else, clippy::comparison_chain)] // all empty blocks
7 fn function() -> bool {
11 fn fn_arg(_arg: u8) -> bool {
18 fn method(&self) -> bool {
21 fn method_arg(&self, _arg: u8) -> bool {
26 fn ifs_same_cond_fn() {
31 } else if function() {
32 //~ ERROR ifs same condition
37 //~ ERROR ifs same condition
41 } else if obj.method() {
42 //~ ERROR ifs same condition
45 if obj.method_arg(a) {
46 } else if obj.method_arg(a) {
47 //~ ERROR ifs same condition
51 if v.pop().is_none() {
52 //~ ERROR ifs same condition
53 } else if v.pop().is_none() {
57 //~ ERROR ifs same condition
58 } else if v.len() == 42 {
62 // ok, different conditions
63 } else if v.len() == 2 {
67 // ok, different arguments.
71 if obj.method_arg(0) {
72 // ok, different arguments.
73 } else if obj.method_arg(1) {
77 // ok, warning is on `ifs_same_cond` behalf.
83 // macro as condition (see #6168)
84 let os = if cfg!(target_os = "macos") {
86 } else if cfg!(target_os = "windows") {
93 #[derive(PartialEq, Eq)]
98 fn generic<const P: E>() -> bool {
104 if generic::<{ E::A }>() {
106 } else if generic::<{ E::B }>() {