@@ -710,8 +710,7 @@ impl f32 {
710
710
pub const fn is_sign_negative ( self ) -> bool {
711
711
// IEEE754 says: isSignMinus(x) is true if and only if x has negative sign. isSignMinus
712
712
// 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
715
714
}
716
715
717
716
/// Returns the least number greater than `self`.
@@ -1096,6 +1095,7 @@ impl f32 {
1096
1095
#[ stable( feature = "float_bits_conv" , since = "1.20.0" ) ]
1097
1096
#[ rustc_const_stable( feature = "const_float_bits_conv" , since = "1.83.0" ) ]
1098
1097
#[ inline]
1098
+ #[ cfg_attr( not( bootstrap) , allow( unnecessary_transmutes) ) ]
1099
1099
pub const fn to_bits ( self ) -> u32 {
1100
1100
// SAFETY: `u32` is a plain old datatype so we can always transmute to it.
1101
1101
unsafe { mem:: transmute ( self ) }
@@ -1141,6 +1141,7 @@ impl f32 {
1141
1141
#[ rustc_const_stable( feature = "const_float_bits_conv" , since = "1.83.0" ) ]
1142
1142
#[ must_use]
1143
1143
#[ inline]
1144
+ #[ cfg_attr( not( bootstrap) , allow( unnecessary_transmutes) ) ]
1144
1145
pub const fn from_bits ( v : u32 ) -> Self {
1145
1146
// It turns out the safety issues with sNaN were overblown! Hooray!
1146
1147
// SAFETY: `u32` is a plain old datatype so we can always transmute from it.
0 commit comments