]> git.lizzy.rs Git - rust.git/blob - tests/ui/enum/enum-to-float-cast.rs
Rollup merge of #107194 - xfix:remove-slice-internals-dependency-in-rustc-ast, r...
[rust.git] / tests / ui / enum / enum-to-float-cast.rs
1 // Tests that enum-to-float casts are disallowed.
2
3 enum E {
4     L0 = -1,
5     H0 = 1
6 }
7
8 enum F {
9     L1 = 1,
10     H1 = 0xFFFFFFFFFFFFFFFF
11 }
12
13 static C0: f32 = E::L0 as f32; //~ ERROR casting
14 static C1: f32 = F::H1 as f32; //~ ERROR casting
15
16 pub fn main() {
17     let b = C0;
18     let d = C1;
19     assert_eq!(b, -1.0f32);
20     assert_eq!(d, -1.0f32);
21 }