Skip to content

Commit 1a33b9c

Browse files
committed
Remove unsafe from consts clippy lints
1 parent 3c4abb5 commit 1a33b9c

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

clippy_lints/src/consts.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,14 @@ impl PartialEq for Constant {
6161
(&Constant::F64(l), &Constant::F64(r)) => {
6262
// we want `Fw32 == FwAny` and `FwAny == Fw64`, by transitivity we must have
6363
// `Fw32 == Fw64` so don’t compare them
64-
// mem::transmute is required to catch non-matching 0.0, -0.0, and NaNs
65-
unsafe { mem::transmute::<f64, u64>(l) == mem::transmute::<f64, u64>(r) }
64+
// to_bits is required to catch non-matching 0.0, -0.0, and NaNs
65+
l.to_bits() == r.to_bits()
6666
},
6767
(&Constant::F32(l), &Constant::F32(r)) => {
6868
// we want `Fw32 == FwAny` and `FwAny == Fw64`, by transitivity we must have
6969
// `Fw32 == Fw64` so don’t compare them
70-
// mem::transmute is required to catch non-matching 0.0, -0.0, and NaNs
71-
unsafe { mem::transmute::<f64, u64>(f64::from(l)) == mem::transmute::<f64, u64>(f64::from(r)) }
70+
// to_bits is required to catch non-matching 0.0, -0.0, and NaNs
71+
f64::from(l).to_bits() == f64::from(r).to_bits()
7272
},
7373
(&Constant::Bool(l), &Constant::Bool(r)) => l == r,
7474
(&Constant::Vec(ref l), &Constant::Vec(ref r)) | (&Constant::Tuple(ref l), &Constant::Tuple(ref r)) => {
@@ -99,10 +99,10 @@ impl Hash for Constant {
9999
i.hash(state);
100100
},
101101
Constant::F32(f) => {
102-
unsafe { mem::transmute::<f64, u64>(f64::from(f)) }.hash(state);
102+
f64::from(f).to_bits().hash(state);
103103
},
104104
Constant::F64(f) => {
105-
unsafe { mem::transmute::<f64, u64>(f) }.hash(state);
105+
f.to_bits().hash(state);
106106
},
107107
Constant::Bool(b) => {
108108
b.hash(state);

0 commit comments

Comments
 (0)