@@ -921,19 +921,9 @@ impl f64 {
921
921
FpCategory :: Subnormal => {
922
922
panic ! ( "const-eval error: cannot use f64::to_bits on a subnormal number" )
923
923
}
924
- FpCategory :: Infinite =>
925
- // SAFETY: Infinity per se is fine
926
- unsafe { mem:: transmute :: < f64 , u64 > ( ct) } ,
927
- FpCategory :: Zero | FpCategory :: Normal => {
924
+ FpCategory :: Infinite | FpCategory :: Normal | FpCategory :: Zero => {
928
925
// SAFETY: We have a normal floating point number. Now we transmute, i.e. do a bitcopy.
929
- let bits: u64 = unsafe { mem:: transmute :: < f64 , u64 > ( ct) } ;
930
- // Let's doublecheck to make sure it wasn't a weird float by truncating it.
931
- if ( bits >> 52 ) & 0x7FF == 0x7FF {
932
- panic ! (
933
- "const-eval error: an unusually large x87 floating point value should not leak into const eval"
934
- )
935
- } ;
936
- bits
926
+ unsafe { mem:: transmute :: < f64 , u64 > ( ct) }
937
927
}
938
928
}
939
929
}
@@ -1019,13 +1009,15 @@ impl f64 {
1019
1009
const fn ct_u64_to_f64 ( ct : u64 ) -> f64 {
1020
1010
match f64:: classify_bits ( ct) {
1021
1011
FpCategory :: Subnormal => {
1022
- panic ! ( "const-eval error: cannot use f64::from_bits on a subnormal number" ) ;
1012
+ panic ! ( "const-eval error: cannot use f64::from_bits on a subnormal number" )
1023
1013
}
1024
1014
FpCategory :: Nan => {
1025
- panic ! ( "const-eval error: cannot use f64::from_bits on NaN" ) ;
1015
+ panic ! ( "const-eval error: cannot use f64::from_bits on NaN" )
1016
+ }
1017
+ FpCategory :: Infinite | FpCategory :: Normal | FpCategory :: Zero => {
1018
+ // SAFETY: It's not a frumious number
1019
+ unsafe { mem:: transmute :: < u64 , f64 > ( ct) }
1026
1020
}
1027
- // SAFETY: It's not a frumious number
1028
- _ => unsafe { mem:: transmute :: < u64 , f64 > ( ct) } ,
1029
1021
}
1030
1022
}
1031
1023
// SAFETY: `u64` is a plain old datatype so we can always... uh...
0 commit comments