]> git.proxmox.com Git - rustc.git/blob - src/test/ui/pattern/pat-tuple-underfield.rs
New upstream version 1.57.0+dfsg1
[rustc.git] / src / test / ui / pattern / pat-tuple-underfield.rs
1 struct S(i32, f32);
2 enum E {
3 S(i32, f32),
4 }
5 struct Point4(i32, i32, i32, i32);
6
7 fn main() {
8 match S(0, 1.0) {
9 S(x) => {}
10 //~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields
11 //~| HELP use `_` to explicitly ignore each field
12 }
13 match S(0, 1.0) {
14 S(_) => {}
15 //~^ ERROR this pattern has 1 field, but the corresponding tuple struct has 2 fields
16 //~| HELP use `_` to explicitly ignore each field
17 //~| HELP use `..` to ignore all fields
18 }
19 match S(0, 1.0) {
20 S() => {}
21 //~^ ERROR this pattern has 0 fields, but the corresponding tuple struct has 2 fields
22 //~| HELP use `_` to explicitly ignore each field
23 //~| HELP use `..` to ignore all fields
24
25 // Test non-standard formatting
26 S () => {}
27 //~^ ERROR this pattern has 0 fields, but the corresponding tuple struct has 2 fields
28 //~| HELP use `_` to explicitly ignore each field
29 //~| HELP use `..` to ignore all fields
30 }
31
32 match E::S(0, 1.0) {
33 E::S(x) => {}
34 //~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields
35 //~| HELP use `_` to explicitly ignore each field
36 }
37 match E::S(0, 1.0) {
38 E::S(_) => {}
39 //~^ ERROR this pattern has 1 field, but the corresponding tuple variant has 2 fields
40 //~| HELP use `_` to explicitly ignore each field
41 //~| HELP use `..` to ignore all fields
42 }
43 match E::S(0, 1.0) {
44 E::S() => {}
45 //~^ ERROR this pattern has 0 fields, but the corresponding tuple variant has 2 fields
46 //~| HELP use `_` to explicitly ignore each field
47 //~| HELP use `..` to ignore all fields
48
49 // Test non-standard formatting
50 E::S () => {}
51 //~^ ERROR this pattern has 0 fields, but the corresponding tuple variant has 2 fields
52 //~| HELP use `_` to explicitly ignore each field
53 //~| HELP use `..` to ignore all fields
54 }
55 match E::S(0, 1.0) {
56 E::S => {}
57 //~^ ERROR expected unit struct, unit variant or constant, found tuple variant `E::S`
58 //~| HELP use the tuple variant pattern syntax instead
59 }
60
61 match Point4(0, 1, 2, 3) {
62 Point4( a , _ ) => {}
63 //~^ ERROR this pattern has 2 fields, but the corresponding tuple struct has 4 fields
64 //~| HELP use `_` to explicitly ignore each field
65 //~| HELP use `..` to ignore the rest of the fields
66 }
67 }