]> git.lizzy.rs Git - rust.git/blob - tests/ui/packed/packed-struct-match.rs
Rollup merge of #107576 - P1n3appl3:master, r=tmandry
[rust.git] / tests / ui / packed / packed-struct-match.rs
1 // run-pass
2
3 #[repr(packed)]
4 struct Foo1 {
5     bar: u8,
6     baz: usize
7 }
8
9 #[repr(packed(2))]
10 struct Foo2 {
11     bar: u8,
12     baz: usize
13 }
14
15 #[repr(C, packed(4))]
16 struct Foo4C {
17     bar: u8,
18     baz: usize
19 }
20
21 pub fn main() {
22     let foo1 = Foo1 { bar: 1, baz: 2 };
23     match foo1 {
24         Foo1 {bar, baz} => {
25             assert_eq!(bar, 1);
26             assert_eq!(baz, 2);
27         }
28     }
29
30     let foo2 = Foo2 { bar: 1, baz: 2 };
31     match foo2 {
32         Foo2 {bar, baz} => {
33             assert_eq!(bar, 1);
34             assert_eq!(baz, 2);
35         }
36     }
37
38     let foo4 = Foo4C { bar: 1, baz: 2 };
39     match foo4 {
40         Foo4C {bar, baz} => {
41             assert_eq!(bar, 1);
42             assert_eq!(baz, 2);
43         }
44     }
45 }