]> git.lizzy.rs Git - rust.git/blobdiff - tests/ui/wildcard_enum_match_arm.rs
Rollup merge of #92849 - flip1995:clippyup, r=Manishearth
[rust.git] / tests / ui / wildcard_enum_match_arm.rs
index 049596d342e8e0b57916e8019670f886f83285ff..46886550453308a340353c5a8c9c8b143a0877a9 100644 (file)
@@ -1,7 +1,20 @@
 // run-rustfix
+// aux-build:non-exhaustive-enum.rs
 
 #![deny(clippy::wildcard_enum_match_arm)]
-#![allow(unreachable_code, unused_variables, dead_code)]
+#![allow(
+    unreachable_code,
+    unused_variables,
+    dead_code,
+    clippy::single_match,
+    clippy::wildcard_in_or_patterns,
+    clippy::unnested_or_patterns,
+    clippy::diverging_sub_expression
+)]
+
+extern crate non_exhaustive_enum;
+
+use non_exhaustive_enum::ErrorKind;
 
 #[derive(Clone, Copy, Debug, Eq, PartialEq)]
 enum Color {
@@ -62,4 +75,30 @@ fn main() {
         140 => {},
         _ => {},
     };
+    // We need to use an enum not defined in this test because non_exhaustive is ignored for the
+    // purposes of dead code analysis within a crate.
+    let error_kind = ErrorKind::NotFound;
+    match error_kind {
+        ErrorKind::NotFound => {},
+        _ => {},
+    }
+    match error_kind {
+        ErrorKind::NotFound => {},
+        ErrorKind::PermissionDenied => {},
+        _ => {},
+    }
+
+    {
+        #![allow(clippy::manual_non_exhaustive)]
+        pub enum Enum {
+            A,
+            B,
+            #[doc(hidden)]
+            __Private,
+        }
+        match Enum::A {
+            Enum::A => (),
+            _ => (),
+        }
+    }
 }