]> git.proxmox.com Git - rustc.git/blobdiff - src/test/ui/rfc-2008-non-exhaustive/stable-omitted-patterns.rs
New upstream version 1.61.0+dfsg1
[rustc.git] / src / test / ui / rfc-2008-non-exhaustive / stable-omitted-patterns.rs
index 9621d28f8e22bf68e1af52c09ef6355af557fb11..82ee68687ed00b12127aeb4a13ce707f080f1e4f 100644 (file)
@@ -6,7 +6,7 @@
 // aux-build:unstable.rs
 extern crate unstable;
 
-use unstable::{UnstableEnum, OnlyUnstableEnum};
+use unstable::{UnstableEnum, OnlyUnstableEnum, UnstableStruct, OnlyUnstableStruct};
 
 fn main() {
     // OK: this matches all the stable variants
@@ -30,4 +30,16 @@ fn main() {
     match OnlyUnstableEnum::new() {
         _ => {}
     }
+
+    // Ok: Same as the above enum (no fields can be matched on)
+    #[warn(non_exhaustive_omitted_patterns)]
+    let OnlyUnstableStruct { .. } = OnlyUnstableStruct::new();
+
+    #[warn(non_exhaustive_omitted_patterns)]
+    let UnstableStruct { stable, .. } = UnstableStruct::default();
+    //~^ some fields are not explicitly listed
+
+    // OK: stable field is matched
+    #[warn(non_exhaustive_omitted_patterns)]
+    let UnstableStruct { stable, stable2, .. } = UnstableStruct::default();
 }