Overflow warning when working with primitive enums

Provided this playground example: https://play.rust-lang.org/?gist=db1c3fbd87d5a92e5a64c149b1188ad9&version=stable&mode=debug

I expected the compiler to emit 2 overflow warnings, one for the manual coercion and one for the enum invariant coercion.
Is there a way to make the compiler realise there is an overflow happening when coercing enum values?

Maybe put #[repr(u8)] on top of the enum.

1 Like