]> git.lizzy.rs Git - rust.git/blob - tests/ui/numbers-arithmetic/float-int-invalid-const-cast.rs
Rollup merge of #106644 - alexcrichton:update-wasi-toolchain, r=cuviper
[rust.git] / tests / ui / numbers-arithmetic / float-int-invalid-const-cast.rs
1 // run-pass
2
3 // Forces evaluation of constants, triggering hard error
4 fn force<T>(_: T) {}
5
6 fn main() {
7     { const X: u16 = -1. as u16; force(X); }
8     { const X: u128 = -100. as u128; force(X); }
9
10     { const X: i8 = f32::NAN as i8; force(X); }
11     { const X: i32 = f32::NAN as i32; force(X); }
12     { const X: u64 = f32::NAN as u64; force(X); }
13     { const X: u128 = f32::NAN as u128; force(X); }
14
15     { const X: i8 = f32::INFINITY as i8; force(X); }
16     { const X: u32 = f32::INFINITY as u32; force(X); }
17     { const X: i128 = f32::INFINITY as i128; force(X); }
18     { const X: u128 = f32::INFINITY as u128; force(X); }
19
20     { const X: u8 = f32::NEG_INFINITY as u8; force(X); }
21     { const X: u16 = f32::NEG_INFINITY as u16; force(X); }
22     { const X: i64 = f32::NEG_INFINITY as i64; force(X); }
23     { const X: i128 = f32::NEG_INFINITY as i128; force(X); }
24
25     { const X: i8 = f64::NAN as i8; force(X); }
26     { const X: i32 = f64::NAN as i32; force(X); }
27     { const X: u64 = f64::NAN as u64; force(X); }
28     { const X: u128 = f64::NAN as u128; force(X); }
29
30     { const X: i8 = f64::INFINITY as i8; force(X); }
31     { const X: u32 = f64::INFINITY as u32; force(X); }
32     { const X: i128 = f64::INFINITY as i128; force(X); }
33     { const X: u128 = f64::INFINITY as u128; force(X); }
34
35     { const X: u8 = f64::NEG_INFINITY as u8; force(X); }
36     { const X: u16 = f64::NEG_INFINITY as u16; force(X); }
37     { const X: i64 = f64::NEG_INFINITY as i64; force(X); }
38     { const X: i128 = f64::NEG_INFINITY as i128; force(X); }
39
40     { const X: u8 = 256. as u8; force(X); }
41     { const X: i8 = -129. as i8; force(X); }
42     { const X: i8 = 128. as i8; force(X); }
43     { const X: i32 = 2147483648. as i32; force(X); }
44     { const X: i32 = -2147483904. as i32; force(X); }
45     { const X: u32 = 4294967296. as u32; force(X); }
46     { const X: u128 = 1e40 as u128; force(X); }
47     { const X: i128 = 1e40 as i128; force(X); }
48 }