2 use std::mem::transmute;
4 fn get_flag<const FlagSet: bool, const ShortName: char>() -> Option<char> {
22 const char_raw: CharRaw = CharRaw { byte: 0xFF };
23 const bool_raw: BoolRaw = BoolRaw { byte: 0x42 };
26 // Test that basic cases don't work
27 assert!(get_flag::<true, 'c'>().is_some());
28 assert!(get_flag::<false, 'x'>().is_none());
29 get_flag::<false, 0xFF>();
30 //~^ ERROR mismatched types
32 //~^ ERROR mismatched types
33 get_flag::<42, 0x5ad>();
34 //~^ ERROR mismatched types
35 //~| ERROR mismatched types
38 get_flag::<false, { unsafe { char_raw.character } }>();
39 //~^ ERROR it is undefined behavior
40 get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>();
41 //~^ ERROR it is undefined behavior
42 get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>();
43 //~^ ERROR it is undefined behavior
44 //~| ERROR it is undefined behavior