]> git.proxmox.com Git - rustc.git/blob - tests/ui/print_type_sizes/repr-align.rs
New upstream version 1.68.2+dfsg1
[rustc.git] / tests / ui / print_type_sizes / repr-align.rs
1 // compile-flags: -Z print-type-sizes --crate-type=lib
2 // build-pass
3 // ignore-pass
4 // ^-- needed because `--pass check` does not emit the output needed.
5 // FIXME: consider using an attribute instead of side-effects.
6
7 // This file illustrates how padding is handled: alignment
8 // requirements can lead to the introduction of padding, either before
9 // fields or at the end of the structure as a whole.
10 //
11 // It avoids using u64/i64 because on some targets that is only 4-byte
12 // aligned (while on most it is 8-byte aligned) and so the resulting
13 // padding and overall computed sizes can be quite different.
14
15 #![allow(dead_code)]
16
17 #[repr(align(16))]
18 #[derive(Default)]
19 struct A(i32);
20
21 enum E {
22 A(i32),
23 B(A)
24 }
25
26 #[derive(Default)]
27 pub struct S {
28 a: i32,
29 b: i32,
30 c: A,
31 d: i8,
32 }