]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/collapsible_if.fixed
Use macro source when creating `Sugg` helper
[rust.git] / tests / ui / collapsible_if.fixed
index e8f90b3164a9d0e8651c8ec8e4d5caa1adfdce31..6bb7682bae9530883c8035aa3ca0a1aebf5c5cbe 100644 (file)
@@ -1,5 +1,5 @@
 // run-rustfix
-#![allow(clippy::cognitive_complexity, clippy::assertions_on_constants)]
+#![allow(clippy::assertions_on_constants, clippy::equatable_if_let)]
 
 #[rustfmt::skip]
 #[warn(clippy::collapsible_if)]
@@ -7,28 +7,28 @@ fn main() {
     let x = "hello";
     let y = "world";
     if x == "hello" && y == "world" {
-    println!("Hello world!");
-}
+        println!("Hello world!");
+    }
 
     if (x == "hello" || x == "world") && (y == "world" || y == "hello") {
-    println!("Hello world!");
-}
+        println!("Hello world!");
+    }
 
     if x == "hello" && x == "world" && (y == "world" || y == "hello") {
-    println!("Hello world!");
-}
+        println!("Hello world!");
+    }
 
     if (x == "hello" || x == "world") && y == "world" && y == "hello" {
-    println!("Hello world!");
-}
+        println!("Hello world!");
+    }
 
     if x == "hello" && x == "world" && y == "world" && y == "hello" {
-    println!("Hello world!");
-}
+        println!("Hello world!");
+    }
 
     if 42 == 1337 && 'a' != 'A' {
-    println!("world!")
-}
+        println!("world!")
+    }
 
     // Works because any if with an else statement cannot be collapsed.
     if x == "hello" {
@@ -81,8 +81,8 @@ fn main() {
     }
 
     if x == "hello" && y == "world" { // Collapsible
-    println!("Hello world!");
-}
+        println!("Hello world!");
+    }
 
     if x == "hello" {
         print!("Hello ");
@@ -135,4 +135,17 @@ fn main() {
             if truth() {}
         }
     }
+
+    // Fix #5962
+    if matches!(true, true) && matches!(true, true) {}
+
+    // Issue #9375
+    if matches!(true, true) && truth() && matches!(true, true) {}
+
+    if true {
+        #[cfg(not(teehee))]
+        if true {
+            println!("Hello world!");
+        }
+    }
 }