@@ -921,19 +921,9 @@ impl f64 {
921921 FpCategory :: Subnormal => {
922922 panic ! ( "const-eval error: cannot use f64::to_bits on a subnormal number" )
923923 }
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 => {
928925 // 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) }
937927 }
938928 }
939929 }
@@ -1019,13 +1009,15 @@ impl f64 {
10191009 const fn ct_u64_to_f64 ( ct : u64 ) -> f64 {
10201010 match f64:: classify_bits ( ct) {
10211011 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" )
10231013 }
10241014 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) }
10261020 }
1027- // SAFETY: It's not a frumious number
1028- _ => unsafe { mem:: transmute :: < u64 , f64 > ( ct) } ,
10291021 }
10301022 }
10311023 // SAFETY: `u64` is a plain old datatype so we can always... uh...
0 commit comments