From 0dd13b0db2f120577e31bec5c61190eb16d692a3 Mon Sep 17 00:00:00 2001 From: Taylor Cramer Date: Wed, 13 Jul 2016 00:59:35 -0700 Subject: [PATCH] Change floating point constant to mem::transmute u64 comparison --- clippy_lints/src/consts.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/clippy_lints/src/consts.rs b/clippy_lints/src/consts.rs index d4ee7659056..9ed37e70a01 100644 --- a/clippy_lints/src/consts.rs +++ b/clippy_lints/src/consts.rs @@ -92,8 +92,10 @@ fn eq(&self, other: &Constant) -> bool { // we want `Fw32 == FwAny` and `FwAny == Fw64`, by transitivity we must have // `Fw32 == Fw64` so don’t compare them match (ls.parse::(), rs.parse::()) { - (Ok(l), Ok(r)) => l.eq(&r) && - (l.is_sign_positive() == r.is_sign_positive()), // needed for 0.0 != -0.0 + // mem::transmute is required to catch non-matching 0.0, -0.0, and NaNs + (Ok(l), Ok(r)) => unsafe { + mem::transmute::(l) == mem::transmute::(r) + }, _ => false, } } -- 2.44.0