]> git.lizzy.rs Git - rust.git/blob - src/test/ui/binding/pat-tuple-4.rs
Merge commit '6ed6f1e6a1a8f414ba7e6d9b8222e7e5a1686e42' into clippyup
[rust.git] / src / test / ui / binding / pat-tuple-4.rs
1 // run-pass
2 fn tuple() {
3     let x = (1, 2, 3);
4     match x {
5         (1, 2, 4) => unreachable!(),
6         (0, 2, 3, ..) => unreachable!(),
7         (0, .., 3) => unreachable!(),
8         (0, ..) => unreachable!(),
9         (1, 2, 3) => (),
10         (_, _, _) => unreachable!(),
11     }
12     match x {
13         (..) => (),
14     }
15     match x {
16         (_, _, _, ..) => (),
17     }
18     match x {
19         (a, b, c) => {
20             assert_eq!(1, a);
21             assert_eq!(2, b);
22             assert_eq!(3, c);
23         }
24     }
25 }
26
27 fn tuple_struct() {
28     struct S(u8, u8, u8);
29
30     let x = S(1, 2, 3);
31     match x {
32         S(1, 2, 4) => unreachable!(),
33         S(0, 2, 3, ..) => unreachable!(),
34         S(0, .., 3) => unreachable!(),
35         S(0, ..) => unreachable!(),
36         S(1, 2, 3) => (),
37         S(_, _, _) => unreachable!(),
38     }
39     match x {
40         S(..) => (),
41     }
42     match x {
43         S(_, _, _, ..) => (),
44     }
45     match x {
46         S(a, b, c) => {
47             assert_eq!(1, a);
48             assert_eq!(2, b);
49             assert_eq!(3, c);
50         }
51     }
52 }
53
54 fn main() {
55     tuple();
56     tuple_struct();
57 }