diff options
Diffstat (limited to 'tests/ui/print_type_sizes/zero-sized-fields.rs')
-rw-r--r-- | tests/ui/print_type_sizes/zero-sized-fields.rs | 43 |
1 files changed, 43 insertions, 0 deletions
diff --git a/tests/ui/print_type_sizes/zero-sized-fields.rs b/tests/ui/print_type_sizes/zero-sized-fields.rs new file mode 100644 index 000000000..09415824d --- /dev/null +++ b/tests/ui/print_type_sizes/zero-sized-fields.rs @@ -0,0 +1,43 @@ +// compile-flags: -Z print-type-sizes --crate-type=lib +// build-pass +// ignore-pass + +// At one point, zero-sized fields such as those in this file were causing +// incorrect output from `-Z print-type-sizes`. + +struct S1 { + x: u32, + y: u32, + tag: (), +} + +struct Void(); +struct Empty {} + +struct S5<TagW, TagZ> { + tagw: TagW, + w: u32, + unit: (), + x: u32, + void: Void, + y: u32, + empty: Empty, + z: u32, + tagz: TagZ, +} + +pub fn test() { + let _s1: S1 = S1 { x: 0, y: 0, tag: () }; + + let _s5: S5<(), Empty> = S5 { + tagw: (), + w: 1, + unit: (), + x: 2, + void: Void(), + y: 3, + empty: Empty {}, + z: 4, + tagz: Empty {}, + }; +} |