@@ -710,8 +710,7 @@ impl f32 {
710710 pub const fn is_sign_negative ( self ) -> bool {
711711 // IEEE754 says: isSignMinus(x) is true if and only if x has negative sign. isSignMinus
712712 // applies to zeros and NaNs as well.
713- // SAFETY: This is just transmuting to get the sign bit, it's fine.
714- unsafe { mem:: transmute :: < f32 , u32 > ( self ) & 0x8000_0000 != 0 }
713+ self . to_bits ( ) & 0x8000_0000 != 0
715714 }
716715
717716 /// Returns the least number greater than `self`.
@@ -1096,6 +1095,7 @@ impl f32 {
10961095 #[ stable( feature = "float_bits_conv" , since = "1.20.0" ) ]
10971096 #[ rustc_const_stable( feature = "const_float_bits_conv" , since = "1.83.0" ) ]
10981097 #[ inline]
1098+ #[ cfg_attr( not( bootstrap) , allow( unnecessary_transmutes) ) ]
10991099 pub const fn to_bits ( self ) -> u32 {
11001100 // SAFETY: `u32` is a plain old datatype so we can always transmute to it.
11011101 unsafe { mem:: transmute ( self ) }
@@ -1141,6 +1141,7 @@ impl f32 {
11411141 #[ rustc_const_stable( feature = "const_float_bits_conv" , since = "1.83.0" ) ]
11421142 #[ must_use]
11431143 #[ inline]
1144+ #[ cfg_attr( not( bootstrap) , allow( unnecessary_transmutes) ) ]
11441145 pub const fn from_bits ( v : u32 ) -> Self {
11451146 // It turns out the safety issues with sNaN were overblown! Hooray!
11461147 // SAFETY: `u32` is a plain old datatype so we can always transmute from it.
0 commit comments