about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/test/ui/pattern/pat-tuple-underfield.rs8
-rw-r--r--src/test/ui/pattern/pat-tuple-underfield.stderr34
2 files changed, 34 insertions, 8 deletions
diff --git a/src/test/ui/pattern/pat-tuple-underfield.rs b/src/test/ui/pattern/pat-tuple-underfield.rs
index f86d6178014..50f8a855d36 100644
--- a/src/test/ui/pattern/pat-tuple-underfield.rs
+++ b/src/test/ui/pattern/pat-tuple-underfield.rs
@@ -2,6 +2,7 @@ struct S(i32, f32);
 enum E {
     S(i32, f32),
 }
+struct Point4(i32, i32, i32, i32);
 
 fn main() {
     match S(0, 1.0) {
@@ -42,4 +43,11 @@ fn main() {
         //~^ ERROR expected unit struct, unit variant or constant, found tuple variant `E::S`
         //~| HELP use the tuple variant pattern syntax instead
     }
+
+    match Point4(0, 1, 2, 3) {
+        Point4(   a   ,     _    ) => {}
+        //~^ ERROR this pattern has 2 fields, but the corresponding tuple struct has 4 fields
+        //~| HELP use `_` to explicitly ignore each field
+        //~| HELP use `..` to ignore the rest of the fields
+    }
 }
diff --git a/src/test/ui/pattern/pat-tuple-underfield.stderr b/src/test/ui/pattern/pat-tuple-underfield.stderr
index 6e7afd8e57b..df6b216272e 100644
--- a/src/test/ui/pattern/pat-tuple-underfield.stderr
+++ b/src/test/ui/pattern/pat-tuple-underfield.stderr
@@ -1,5 +1,5 @@
 error[E0532]: expected unit struct, unit variant or constant, found tuple variant `E::S`
-  --> $DIR/pat-tuple-underfield.rs:41:9
+  --> $DIR/pat-tuple-underfield.rs:42:9
    |
 LL |     S(i32, f32),
    |     ----------- `E::S` defined here
@@ -8,7 +8,7 @@ LL |         E::S => {}
    |         ^^^^ help: use the tuple variant pattern syntax instead: `E::S(_, _)`
 
 error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
-  --> $DIR/pat-tuple-underfield.rs:8:9
+  --> $DIR/pat-tuple-underfield.rs:9:9
    |
 LL | struct S(i32, f32);
    | ------------------- tuple struct defined here
@@ -20,7 +20,7 @@ LL |         S(x) => {}
    |         expected 2 fields, found 1
 
 error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
-  --> $DIR/pat-tuple-underfield.rs:13:9
+  --> $DIR/pat-tuple-underfield.rs:14:9
    |
 LL | struct S(i32, f32);
    | ------------------- tuple struct defined here
@@ -32,7 +32,7 @@ LL |         S(_) => {}
    |         expected 2 fields, found 1
 
 error[E0023]: this pattern has 0 fields, but the corresponding tuple struct has 2 fields
-  --> $DIR/pat-tuple-underfield.rs:18:9
+  --> $DIR/pat-tuple-underfield.rs:19:9
    |
 LL | struct S(i32, f32);
    | ------------------- tuple struct defined here
@@ -50,7 +50,7 @@ LL |         S(..) => {}
    |           ^^
 
 error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
-  --> $DIR/pat-tuple-underfield.rs:25:9
+  --> $DIR/pat-tuple-underfield.rs:26:9
    |
 LL |     S(i32, f32),
    |     ----------- tuple variant defined here
@@ -62,7 +62,7 @@ LL |         E::S(x) => {}
    |         expected 2 fields, found 1
 
 error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
-  --> $DIR/pat-tuple-underfield.rs:30:9
+  --> $DIR/pat-tuple-underfield.rs:31:9
    |
 LL |     S(i32, f32),
    |     ----------- tuple variant defined here
@@ -74,7 +74,7 @@ LL |         E::S(_) => {}
    |         expected 2 fields, found 1
 
 error[E0023]: this pattern has 0 fields, but the corresponding tuple variant has 2 fields
-  --> $DIR/pat-tuple-underfield.rs:35:9
+  --> $DIR/pat-tuple-underfield.rs:36:9
    |
 LL |     S(i32, f32),
    |     ----------- tuple variant defined here
@@ -91,7 +91,25 @@ help: use `..` to ignore all fields
 LL |         E::S(..) => {}
    |              ^^
 
-error: aborting due to 7 previous errors
+error[E0023]: this pattern has 2 fields, but the corresponding tuple struct has 4 fields
+  --> $DIR/pat-tuple-underfield.rs:48:9
+   |
+LL | struct Point4(i32, i32, i32, i32);
+   | ---------------------------------- tuple struct defined here
+...
+LL |         Point4(   a   ,     _    ) => {}
+   |         ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 4 fields, found 2
+   |
+help: use `_` to explicitly ignore each field
+   |
+LL |         Point4(   a   ,     _    , _, _) => {}
+   |                                  ^^^^^^
+help: use `..` to ignore the rest of the fields
+   |
+LL |         Point4(   a   ,     _    , ..) => {}
+   |                                  ^^^^
+
+error: aborting due to 8 previous errors
 
 Some errors have detailed explanations: E0023, E0532.
 For more information about an error, try `rustc --explain E0023`.