]> git.lizzy.rs Git - rust.git/blob - tests/ui/enum/enum-discrim-too-small2.rs
Merge commit '7f27e2e74ef957baa382dc05cf08df6368165c74' into clippyup
[rust.git] / tests / ui / enum / enum-discrim-too-small2.rs
1 #![deny(overflowing_literals)]
2 #![allow(dead_code)]
3
4 #[repr(i8)]
5 enum Ei8 {
6     Ai8 = 23,
7     Bi8 = -23,
8     Ci8 = 223, //~ ERROR literal out of range for `i8`
9 }
10
11 #[repr(i16)]
12 enum Ei16 {
13     Ai16 = 23,
14     Bi16 = -22333,
15     Ci16 = 55555, //~ ERROR literal out of range for `i16`
16 }
17
18 #[repr(i32)]
19 enum Ei32 {
20     Ai32 = 23,
21     Bi32 = -2_000_000_000,
22     Ci32 = 3_000_000_000, //~ ERROR literal out of range for `i32`
23 }
24
25 #[repr(i64)]
26 enum Ei64 {
27     Ai64 = 23,
28     Bi64 = -9223372036854775808,
29     Ci64 = 9223372036854775809, //~ ERROR literal out of range for `i64`
30 }
31
32 // u64 currently allows negative numbers, and i64 allows numbers greater than `1<<63`.  This is a
33 // little counterintuitive, but since the discriminant can store all the bits, and extracting it
34 // with a cast requires specifying the signedness, there is no loss of information in those cases.
35 // This also applies to isize and usize on 64-bit targets.
36
37 pub fn main() { }