about summary refs log tree commit diff
path: root/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs
diff options
context:
space:
mode:
authorvarkor <github@varkor.com>2018-04-30 01:27:37 +0100
committervarkor <github@varkor.com>2018-04-30 01:27:37 +0100
commit2eb8343af18470d3c48a50c68dbaeb1887b42c37 (patch)
tree6f97cfbaa41fd0d2cfdcde2b0545ea913cd291e0 /src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs
parent8e8fe9042c86c53d90ce17cc0754505bf014d0ed (diff)
downloadrust-2eb8343af18470d3c48a50c68dbaeb1887b42c37.tar.gz
rust-2eb8343af18470d3c48a50c68dbaeb1887b42c37.zip
Correct unused field warning on struct match container patterns
Diffstat (limited to 'src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs')
-rw-r--r--src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs
index db3c812f259..6994a377a06 100644
--- a/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs
+++ b/src/test/ui/lint/issue-47390-unused-variable-in-struct-pattern.rs
@@ -20,10 +20,13 @@ struct SoulHistory {
     endless_and_singing: bool
 }
 
+#[derive(Clone, Copy)]
 enum Large {
     Suit { case: () }
 }
 
+struct Tuple(Large, ());
+
 fn main() {
     let i_think_continually = 2;
     let who_from_the_womb_remembered = SoulHistory {
@@ -42,11 +45,33 @@ fn main() {
         case: ()
     };
 
+    // Plain struct
+    match bag {
+        Large::Suit { case } => {}
+    };
+
+    // Referenced struct
     match &bag {
         &Large::Suit { case } => {}
     };
 
+    // Boxed struct
     match box bag {
         box Large::Suit { case } => {}
     };
+
+    // Tuple with struct
+    match (bag,) {
+        (Large::Suit { case },) => {}
+    };
+
+    // Slice with struct
+    match [bag] {
+        [Large::Suit { case }] => {}
+    };
+
+    // Tuple struct with struct
+    match Tuple(bag, ()) {
+        Tuple(Large::Suit { case }, ()) => {}
+    };
 }