summaryrefslogtreecommitdiffstats
path: root/tests/ui/enum/enum-to-float-cast.rs
blob: 05acdfd34e29fa73ff189e7c2cf3085cce18f04b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
// Tests that enum-to-float casts are disallowed.

enum E {
    L0 = -1,
    H0 = 1
}

enum F {
    L1 = 1,
    H1 = 0xFFFFFFFFFFFFFFFF
}

static C0: f32 = E::L0 as f32; //~ ERROR casting
static C1: f32 = F::H1 as f32; //~ ERROR casting

pub fn main() {
    let b = C0;
    let d = C1;
    assert_eq!(b, -1.0f32);
    assert_eq!(d, -1.0f32);
}