]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/same_functions_in_if_condition.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / same_functions_in_if_condition.rs
index 686867cf5c6f661df745266fea2860e3ccd10b7d..e6198a1bc9a07cd01a8a0d65fcbf636407f467ff 100644 (file)
@@ -1,6 +1,14 @@
+#![feature(adt_const_params)]
 #![warn(clippy::same_functions_in_if_condition)]
-#![allow(clippy::ifs_same_cond)] // This warning is different from `ifs_same_cond`.
-#![allow(clippy::if_same_then_else, clippy::comparison_chain)] // all empty blocks
+// ifs_same_cond warning is different from `ifs_same_cond`.
+// clippy::if_same_then_else, clippy::comparison_chain -- all empty blocks
+#![allow(incomplete_features)]
+#![allow(
+    clippy::comparison_chain,
+    clippy::if_same_then_else,
+    clippy::ifs_same_cond,
+    clippy::uninlined_format_args
+)]
 
 fn function() -> bool {
     true
@@ -46,9 +54,9 @@ fn ifs_same_cond_fn() {
     }
 
     let mut v = vec![1];
-    if v.pop() == None {
+    if v.pop().is_none() {
         //~ ERROR ifs same condition
-    } else if v.pop() == None {
+    } else if v.pop().is_none() {
     }
 
     if v.len() == 42 {
@@ -77,4 +85,31 @@ fn ifs_same_cond_fn() {
     }
 }
 
-fn main() {}
+fn main() {
+    // macro as condition (see #6168)
+    let os = if cfg!(target_os = "macos") {
+        "macos"
+    } else if cfg!(target_os = "windows") {
+        "windows"
+    } else {
+        "linux"
+    };
+    println!("{}", os);
+
+    #[derive(PartialEq, Eq)]
+    enum E {
+        A,
+        B,
+    }
+    fn generic<const P: E>() -> bool {
+        match P {
+            E::A => true,
+            E::B => false,
+        }
+    }
+    if generic::<{ E::A }>() {
+        println!("A");
+    } else if generic::<{ E::B }>() {
+        println!("B");
+    }
+}