]>
Commit | Line | Data |
---|---|---|
9346a6ac | 1 | // Copyright 2012 The Rust Project Developers. See the COPYRIGHT |
223e47cc LB |
2 | // file at the top-level directory of this distribution and at |
3 | // http://rust-lang.org/COPYRIGHT. | |
4 | // | |
5 | // Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or | |
6 | // http://www.apache.org/licenses/LICENSE-2.0> or the MIT license | |
7 | // <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your | |
8 | // option. This file may not be copied, modified, or distributed | |
9 | // except according to those terms. | |
10 | ||
9346a6ac | 11 | // Tests that enum-to-float casts are disallowed. |
c34b1796 | 12 | |
9346a6ac AL |
13 | enum E { |
14 | L0 = -1, | |
15 | H0 = 1 | |
16 | } | |
c34b1796 | 17 | |
9346a6ac AL |
18 | enum F { |
19 | L1 = 1, | |
20 | H1 = 0xFFFFFFFFFFFFFFFF | |
21 | } | |
223e47cc LB |
22 | |
23 | pub fn main() { | |
c1a9b12d SL |
24 | let a = E::L0 as f32; //~ ERROR casting |
25 | let c = F::H1 as f32; //~ ERROR casting | |
9346a6ac AL |
26 | assert_eq!(a, -1.0f32); |
27 | assert_eq!(c, -1.0f32); | |
223e47cc | 28 | } |