]> git.lizzy.rs Git - rust.git/blob - src/test/ui/structs-enums/struct-aliases.rs
Auto merge of #87284 - Aaron1011:remove-paren-special, r=petrochenkov
[rust.git] / src / test / ui / structs-enums / struct-aliases.rs
1 // run-pass
2 #![allow(non_shorthand_field_patterns)]
3
4 use std::mem;
5
6 struct S {
7     x: isize,
8     y: isize,
9 }
10
11 type S2 = S;
12
13 struct S3<U,V> {
14     x: U,
15     y: V
16 }
17
18 type S4<U> = S3<U, char>;
19
20 fn main() {
21     let s = S2 {
22         x: 1,
23         y: 2,
24     };
25     match s {
26         S2 {
27             x: x,
28             y: y
29         } => {
30             assert_eq!(x, 1);
31             assert_eq!(y, 2);
32         }
33     }
34     // check that generics can be specified from the pattern
35     let s = S4 {
36         x: 4,
37         y: 'a'
38     };
39     match s {
40         S4::<u8> {
41             x: x,
42             y: y
43         } => {
44             assert_eq!(x, 4);
45             assert_eq!(y, 'a');
46             assert_eq!(mem::size_of_val(&x), 1);
47         }
48     };
49     // check that generics can be specified from the constructor
50     let s = S4::<u16> {
51         x: 5,
52         y: 'b'
53     };
54     match s {
55         S4 {
56             x: x,
57             y: y
58         } => {
59             assert_eq!(x, 5);
60             assert_eq!(y, 'b');
61             assert_eq!(mem::size_of_val(&x), 2);
62         }
63     };
64 }