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