]> git.proxmox.com Git - rustc.git/blame - src/test/ui/repr/aligned_enum_cast.rs
Update unsuspicious file list
[rustc.git] / src / test / ui / repr / aligned_enum_cast.rs
CommitLineData
5099ac24
FG
1// run-pass
2// allows aligned custom discriminant enums to cast into other types
3// See the issue #92464 for more info
4#[allow(dead_code)]
5#[repr(align(8))]
6enum Aligned {
7 Zero = 0,
8 One = 1,
9}
10
11fn main() {
12 let aligned = Aligned::Zero;
13 let fo = aligned as u8;
064997fb
FG
14 println!("foo {}", fo);
15 assert_eq!(fo, 0);
16 println!("{}", tou8(Aligned::Zero));
17 assert_eq!(tou8(Aligned::Zero), 0);
18}
19
20#[inline(never)]
21fn tou8(al: Aligned) -> u8 {
22 // Cast behind a function call so ConstProp does not see it
23 // (so that we can test codegen).
24 al as u8
5099ac24 25}