]> git.proxmox.com Git - rustc.git/blame - src/test/ui/binding/pat-tuple-1.rs
Merge tag 'debian/1.52.1+dfsg1-1_exp2' into proxmox/buster
[rustc.git] / src / test / ui / binding / pat-tuple-1.rs
CommitLineData
b7449926 1// run-pass
3157f602
XL
2fn tuple() {
3 let x = (1, 2, 3);
4 match x {
5 (a, b, ..) => {
6 assert_eq!(a, 1);
7 assert_eq!(b, 2);
8 }
9 }
10 match x {
11 (.., b, c) => {
12 assert_eq!(b, 2);
13 assert_eq!(c, 3);
14 }
15 }
16 match x {
17 (a, .., c) => {
18 assert_eq!(a, 1);
19 assert_eq!(c, 3);
20 }
21 }
22 match x {
23 (a, b, c) => {
24 assert_eq!(a, 1);
25 assert_eq!(b, 2);
26 assert_eq!(c, 3);
27 }
28 }
29 match x {
30 (a, b, c, ..) => {
31 assert_eq!(a, 1);
32 assert_eq!(b, 2);
33 assert_eq!(c, 3);
34 }
35 }
36 match x {
37 (.., a, b, c) => {
38 assert_eq!(a, 1);
39 assert_eq!(b, 2);
40 assert_eq!(c, 3);
41 }
42 }
43}
44
45fn tuple_struct() {
46 struct S(u8, u8, u8);
47
48 let x = S(1, 2, 3);
49 match x {
50 S(a, b, ..) => {
51 assert_eq!(a, 1);
52 assert_eq!(b, 2);
53 }
54 }
55 match x {
56 S(.., b, c) => {
57 assert_eq!(b, 2);
58 assert_eq!(c, 3);
59 }
60 }
61 match x {
62 S(a, .., c) => {
63 assert_eq!(a, 1);
64 assert_eq!(c, 3);
65 }
66 }
67 match x {
68 S(a, b, c) => {
69 assert_eq!(a, 1);
70 assert_eq!(b, 2);
71 assert_eq!(c, 3);
72 }
73 }
74 match x {
75 S(a, b, c, ..) => {
76 assert_eq!(a, 1);
77 assert_eq!(b, 2);
78 assert_eq!(c, 3);
79 }
80 }
81 match x {
82 S(.., a, b, c) => {
83 assert_eq!(a, 1);
84 assert_eq!(b, 2);
85 assert_eq!(c, 3);
86 }
87 }
88}
89
90fn main() {
91 tuple();
92 tuple_struct();
93}