]> git.lizzy.rs Git - rust.git/blob - tests/ui/print_type_sizes/zero-sized-fields.rs
Rollup merge of #107576 - P1n3appl3:master, r=tmandry
[rust.git] / tests / ui / print_type_sizes / zero-sized-fields.rs
1 // compile-flags: -Z print-type-sizes --crate-type=lib
2 // build-pass
3 // ignore-pass
4
5 // At one point, zero-sized fields such as those in this file were causing
6 // incorrect output from `-Z print-type-sizes`.
7
8 struct S1 {
9     x: u32,
10     y: u32,
11     tag: (),
12 }
13
14 struct Void();
15 struct Empty {}
16
17 struct S5<TagW, TagZ> {
18     tagw: TagW,
19     w: u32,
20     unit: (),
21     x: u32,
22     void: Void,
23     y: u32,
24     empty: Empty,
25     z: u32,
26     tagz: TagZ,
27 }
28
29 pub fn test() {
30     let _s1: S1 = S1 { x: 0, y: 0, tag: () };
31
32     let _s5: S5<(), Empty> = S5 {
33         tagw: (),
34         w: 1,
35         unit: (),
36         x: 2,
37         void: Void(),
38         y: 3,
39         empty: Empty {},
40         z: 4,
41         tagz: Empty {},
42     };
43 }