]> git.lizzy.rs Git - rust.git/blob - src/test/ui/pattern/pat-tuple-field-count-cross.rs
Rollup merge of #105555 - krasimirgg:llvm-int-opt-2, r=cuviper
[rust.git] / src / test / ui / pattern / pat-tuple-field-count-cross.rs
1 // aux-build:declarations-for-tuple-field-count-errors.rs
2
3 extern crate declarations_for_tuple_field_count_errors;
4
5 use declarations_for_tuple_field_count_errors::*;
6
7 fn main() {
8     match Z0 {
9         Z0() => {} //~ ERROR expected tuple struct or tuple variant, found unit struct `Z0`
10         Z0(x) => {} //~ ERROR expected tuple struct or tuple variant, found unit struct `Z0`
11     }
12     match Z1() {
13         Z1 => {} //~ ERROR match bindings cannot shadow tuple structs
14         Z1(x) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple struct has 0 fields
15     }
16
17     match S(1, 2, 3) {
18         S() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple struct has 3 fields
19         S(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple struct has 3 fields
20         S(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple struct has 3 fields
21         S(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields
22     }
23     match M(1, 2, 3) {
24         M() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple struct has 3 fields
25         M(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple struct has 3 fields
26         M(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple struct has 3 fields
27         M(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple struct has 3 fields
28     }
29
30     match E1::Z0 {
31         E1::Z0() => {} //~ ERROR expected tuple struct or tuple variant, found unit variant `E1::Z0`
32         E1::Z0(x) => {} //~ ERROR expected tuple struct or tuple variant, found unit variant `E1::Z0`
33     }
34     match E1::Z1() {
35         E1::Z1 => {} //~ ERROR expected unit struct, unit variant or constant, found tuple variant `E1::Z1`
36         E1::Z1(x) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple variant has 0 fields
37     }
38     match E1::S(1, 2, 3) {
39         E1::S() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple variant has 3 fields
40         E1::S(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple variant has 3 fields
41         E1::S(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields
42         E1::S(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple variant has 3 fields
43     }
44
45     match E2::S(1, 2, 3) {
46         E2::S() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple variant has 3 fields
47         E2::S(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple variant has 3 fields
48         E2::S(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields
49         E2::S(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple variant has 3 fields
50     }
51     match E2::M(1, 2, 3) {
52         E2::M() => {} //~ ERROR this pattern has 0 fields, but the corresponding tuple variant has 3 fields
53         E2::M(1) => {} //~ ERROR this pattern has 1 field, but the corresponding tuple variant has 3 fields
54         E2::M(xyz, abc) => {} //~ ERROR this pattern has 2 fields, but the corresponding tuple variant has 3 fields
55         E2::M(1, 2, 3, 4) => {} //~ ERROR this pattern has 4 fields, but the corresponding tuple variant has 3 fields
56     }
57 }