mirror of
https://github.com/rust-lang/rust.git
synced 2026-04-27 18:57:42 +03:00
7025605b8c
Moreover, dereference `ty_layout.align` for `#[rustc_dump_layout(align)]`
to render `align: Align($N bytes)` instead of `align: AbiAlign { abi: Align($N bytes) }`
which contains the same amount of information but it more concise and legible.
35 lines
878 B
Rust
35 lines
878 B
Rust
//@ normalize-stderr: "pref: Align\([1-8] bytes\)" -> "pref: $$PREF_ALIGN"
|
|
//! Various enum layout tests.
|
|
|
|
#![feature(rustc_attrs)]
|
|
#![feature(never_type)]
|
|
#![crate_type = "lib"]
|
|
|
|
#[rustc_dump_layout(align)]
|
|
enum UninhabitedVariantAlign { //~ERROR: align: Align(2 bytes)
|
|
A([u8; 32]),
|
|
B([u16; 0], !), // make sure alignment in uninhabited fields is respected
|
|
}
|
|
|
|
#[rustc_dump_layout(size)]
|
|
enum UninhabitedVariantSpace { //~ERROR: size: Size(16 bytes)
|
|
A,
|
|
B([u8; 15], !), // make sure there is space being reserved for this field.
|
|
}
|
|
|
|
#[rustc_dump_layout(backend_repr)]
|
|
enum ScalarPairDifferingSign { //~ERROR: backend_repr: ScalarPair
|
|
A(u8),
|
|
B(i8),
|
|
}
|
|
|
|
enum Never {}
|
|
|
|
// See https://github.com/rust-lang/rust/issues/146984
|
|
#[rustc_dump_layout(size)]
|
|
#[repr(u32)]
|
|
enum DefinedLayoutAllUninhabited { //~ERROR: size: Size(4 bytes)
|
|
A(Never),
|
|
B(Never),
|
|
}
|