]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/match_expr_like_matches_macro.rs
Move MSRV tests into the lint specific test files
[rust.git] / tests / ui / match_expr_like_matches_macro.rs
index 2deeb84e74138151920ca91279cef789ebad2e79..b4e48499bd0fb193fca123c306f129d24543e904 100644 (file)
@@ -1,5 +1,6 @@
 // run-rustfix
 
+#![feature(custom_inner_attributes)]
 #![warn(clippy::match_like_matches_macro)]
 #![allow(unreachable_patterns, dead_code, clippy::equatable_if_let)]
 
@@ -61,6 +62,18 @@ enum E {
             _ => false,
         };
     }
+    {
+        // lint
+        // skip rustfmt to prevent removing block for first pattern
+        #[rustfmt::skip]
+        let _ans = match x {
+            E::A(_) => {
+                true
+            }
+            E::B(_) => true,
+            _ => false,
+        };
+    }
     {
         // lint
         let _ans = match x {
@@ -181,4 +194,62 @@ fn fun(_val: Option<S>) {}
         };
         fun(val);
     }
+
+    {
+        enum E {
+            A,
+            B,
+            C,
+        }
+
+        let _ = match E::A {
+            E::B => true,
+            #[cfg(feature = "foo")]
+            E::A => true,
+            _ => false,
+        };
+    }
+
+    let x = ' ';
+    // ignore if match block contains comment
+    let _line_comments = match x {
+        // numbers are bad!
+        '1' | '2' | '3' => true,
+        // spaces are very important to be true.
+        ' ' => true,
+        // as are dots
+        '.' => true,
+        _ => false,
+    };
+
+    let _block_comments = match x {
+        /* numbers are bad!
+         */
+        '1' | '2' | '3' => true,
+        /* spaces are very important to be true.
+         */
+        ' ' => true,
+        /* as are dots
+         */
+        '.' => true,
+        _ => false,
+    };
+}
+
+fn msrv_1_41() {
+    #![clippy::msrv = "1.41"]
+
+    let _y = match Some(5) {
+        Some(0) => true,
+        _ => false,
+    };
+}
+
+fn msrv_1_42() {
+    #![clippy::msrv = "1.42"]
+
+    let _y = match Some(5) {
+        Some(0) => true,
+        _ => false,
+    };
 }