From cf2dff2b1e3fa55fa5415d524200070d0d7aacfe Mon Sep 17 00:00:00 2001 From: Albert Larsan <74931857+albertlarsan68@users.noreply.github.com> Date: Thu, 5 Jan 2023 09:13:28 +0100 Subject: Move /src/test to /tests --- tests/ui/enum/enum-to-float-cast.rs | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 tests/ui/enum/enum-to-float-cast.rs (limited to 'tests/ui/enum/enum-to-float-cast.rs') diff --git a/tests/ui/enum/enum-to-float-cast.rs b/tests/ui/enum/enum-to-float-cast.rs new file mode 100644 index 00000000000..05acdfd34e2 --- /dev/null +++ b/tests/ui/enum/enum-to-float-cast.rs @@ -0,0 +1,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); +} -- cgit 1.4.1-3-g733a5