]> git.proxmox.com Git - rustc.git/blame - src/test/ui/pattern/pat-tuple-overfield.rs
New upstream version 1.56.0~beta.4+dfsg1
[rustc.git] / src / test / ui / pattern / pat-tuple-overfield.rs
CommitLineData
3157f602 1struct S(u8, u8, u8);
94222f64
XL
2struct M(
3 u8,
4 u8,
5 u8,
6 u8,
7 u8,
8);
9
10struct Z0;
11struct Z1();
12enum E1 {
13 Z0,
14 Z1(),
15}
3157f602
XL
16
17fn main() {
18 match (1, 2, 3) {
19 (1, 2, 3, 4) => {} //~ ERROR mismatched types
20 (1, 2, .., 3, 4) => {} //~ ERROR mismatched types
21 _ => {}
22 }
23 match S(1, 2, 3) {
24 S(1, 2, 3, 4) => {}
c30ab7b3 25 //~^ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields
3157f602 26 S(1, 2, .., 3, 4) => {}
c30ab7b3 27 //~^ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields
3157f602
XL
28 _ => {}
29 }
94222f64
XL
30 match M(1, 2, 3, 4, 5) {
31 M(1, 2, 3, 4, 5, 6) => {}
32 //~^ ERROR this pattern has 6 fields, but the corresponding tuple struct has 5 fields
33 M(1,
34 2,
35 3,
36 4,
37 5,
38 6) => {}
39 //~^ ERROR this pattern has 6 fields, but the corresponding tuple struct has 5 fields
40 M(
41 1,
42 2,
43 3,
44 4,
45 5,
46 6,
47 ) => {}
48 //~^^ ERROR this pattern has 6 fields, but the corresponding tuple struct has 5 fields
49 }
50 match Z0 {
51 Z0 => {}
52 Z0() => {} //~ ERROR expected tuple struct or tuple variant, found unit struct `Z0`
53 Z0(_) => {} //~ ERROR expected tuple struct or tuple variant, found unit struct `Z0`
54 Z0(_, _) => {} //~ ERROR expected tuple struct or tuple variant, found unit struct `Z0`
55 }
56 match Z1() {
57 Z1 => {} //~ ERROR match bindings cannot shadow tuple structs
58 Z1() => {}
59 Z1(_) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple struct has 0 fields
60 Z1(_, _) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple struct has 0 fields
61 }
62 match E1::Z0 {
63 E1::Z0 => {}
64 E1::Z0() => {} //~ ERROR expected tuple struct or tuple variant, found unit variant `E1::Z0`
65 E1::Z0(_) => {} //~ ERROR expected tuple struct or tuple variant, found unit variant `E1::Z0`
66 E1::Z0(_, _) => {} //~ ERROR expected tuple struct or tuple variant, found unit variant `E1::Z0`
67 }
68 match E1::Z1() {
69 E1::Z1 => {} //~ ERROR expected unit struct, unit variant or constant, found tuple variant `E1::Z1`
70 E1::Z1() => {}
71 E1::Z1(_) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple variant has 0 fields
72 E1::Z1(_, _) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple variant has 0 fields
73 }
3157f602 74}