You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This code fails with a compile error when using the smaller unsigned types (u8, u16, u32) as a representation for the enum. For signed types or u64 the same code compiles fine so it seems there is some issue with truncation for unsigned types.
As a workaround it is possible to use an explicit cast (!0 as u8).
#[repr(u8)]enumTest{A = 0,B = !0}fnmain(){}
error.rs:6:5: 6:11 error: discriminant value outside specified type [E0082]
error.rs:6 B = !0
^~~~~~
error.rs:3:8: 3:11 note: discriminant type specified here
error.rs:3 #[repr(u8)]