Skip to content

Commit 1bce775

Browse files
committed
Add a test case with lots of whitespace
1 parent 9959d6d commit 1bce775

File tree

2 files changed

+34
-8
lines changed

2 files changed

+34
-8
lines changed

src/test/ui/pattern/pat-tuple-underfield.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ struct S(i32, f32);
22
enum E {
33
S(i32, f32),
44
}
5+
struct Point4(i32, i32, i32, i32);
56

67
fn main() {
78
match S(0, 1.0) {
@@ -42,4 +43,11 @@ fn main() {
4243
//~^ ERROR expected unit struct, unit variant or constant, found tuple variant `E::S`
4344
//~| HELP use the tuple variant pattern syntax instead
4445
}
46+
47+
match Point4(0, 1, 2, 3) {
48+
Point4( a , _ ) => {}
49+
//~^ ERROR this pattern has 2 fields, but the corresponding tuple struct has 4 fields
50+
//~| HELP use `_` to explicitly ignore each field
51+
//~| HELP use `..` to ignore the rest of the fields
52+
}
4553
}

src/test/ui/pattern/pat-tuple-underfield.stderr

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error[E0532]: expected unit struct, unit variant or constant, found tuple variant `E::S`
2-
--> $DIR/pat-tuple-underfield.rs:41:9
2+
--> $DIR/pat-tuple-underfield.rs:42:9
33
|
44
LL | S(i32, f32),
55
| ----------- `E::S` defined here
@@ -8,7 +8,7 @@ LL | E::S => {}
88
| ^^^^ help: use the tuple variant pattern syntax instead: `E::S(_, _)`
99

1010
error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
11-
--> $DIR/pat-tuple-underfield.rs:8:9
11+
--> $DIR/pat-tuple-underfield.rs:9:9
1212
|
1313
LL | struct S(i32, f32);
1414
| ------------------- tuple struct defined here
@@ -20,7 +20,7 @@ LL | S(x) => {}
2020
| expected 2 fields, found 1
2121

2222
error[E0023]: this pattern has 1 field, but the corresponding tuple struct has 2 fields
23-
--> $DIR/pat-tuple-underfield.rs:13:9
23+
--> $DIR/pat-tuple-underfield.rs:14:9
2424
|
2525
LL | struct S(i32, f32);
2626
| ------------------- tuple struct defined here
@@ -32,7 +32,7 @@ LL | S(_) => {}
3232
| expected 2 fields, found 1
3333

3434
error[E0023]: this pattern has 0 fields, but the corresponding tuple struct has 2 fields
35-
--> $DIR/pat-tuple-underfield.rs:18:9
35+
--> $DIR/pat-tuple-underfield.rs:19:9
3636
|
3737
LL | struct S(i32, f32);
3838
| ------------------- tuple struct defined here
@@ -50,7 +50,7 @@ LL | S(..) => {}
5050
| ^^
5151

5252
error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
53-
--> $DIR/pat-tuple-underfield.rs:25:9
53+
--> $DIR/pat-tuple-underfield.rs:26:9
5454
|
5555
LL | S(i32, f32),
5656
| ----------- tuple variant defined here
@@ -62,7 +62,7 @@ LL | E::S(x) => {}
6262
| expected 2 fields, found 1
6363

6464
error[E0023]: this pattern has 1 field, but the corresponding tuple variant has 2 fields
65-
--> $DIR/pat-tuple-underfield.rs:30:9
65+
--> $DIR/pat-tuple-underfield.rs:31:9
6666
|
6767
LL | S(i32, f32),
6868
| ----------- tuple variant defined here
@@ -74,7 +74,7 @@ LL | E::S(_) => {}
7474
| expected 2 fields, found 1
7575

7676
error[E0023]: this pattern has 0 fields, but the corresponding tuple variant has 2 fields
77-
--> $DIR/pat-tuple-underfield.rs:35:9
77+
--> $DIR/pat-tuple-underfield.rs:36:9
7878
|
7979
LL | S(i32, f32),
8080
| ----------- tuple variant defined here
@@ -91,7 +91,25 @@ help: use `..` to ignore all fields
9191
LL | E::S(..) => {}
9292
| ^^
9393

94-
error: aborting due to 7 previous errors
94+
error[E0023]: this pattern has 2 fields, but the corresponding tuple struct has 4 fields
95+
--> $DIR/pat-tuple-underfield.rs:48:9
96+
|
97+
LL | struct Point4(i32, i32, i32, i32);
98+
| ---------------------------------- tuple struct defined here
99+
...
100+
LL | Point4( a , _ ) => {}
101+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^ expected 4 fields, found 2
102+
|
103+
help: use `_` to explicitly ignore each field
104+
|
105+
LL | Point4( a , _ , _, _) => {}
106+
| ^^^^^^
107+
help: use `..` to ignore the rest of the fields
108+
|
109+
LL | Point4( a , _ , ..) => {}
110+
| ^^^^
111+
112+
error: aborting due to 8 previous errors
95113

96114
Some errors have detailed explanations: E0023, E0532.
97115
For more information about an error, try `rustc --explain E0023`.

0 commit comments

Comments
 (0)