diff --git a/library/core/src/num/f128.rs b/library/core/src/num/f128.rs index a551ccfe9ed..90d3035f157 100644 --- a/library/core/src/num/f128.rs +++ b/library/core/src/num/f128.rs @@ -1378,6 +1378,7 @@ impl f128 { #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")] #[must_use = "method returns a new number and does not mutate the original value"] pub const fn copysign(self, sign: f128) -> f128 { + // SAFETY: this is actually a safe intrinsic unsafe { intrinsics::copysignf128(self, sign) } } } diff --git a/library/core/src/num/f16.rs b/library/core/src/num/f16.rs index 0d77377af74..85b2ad18886 100644 --- a/library/core/src/num/f16.rs +++ b/library/core/src/num/f16.rs @@ -1352,6 +1352,7 @@ impl f16 { #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")] #[must_use = "method returns a new number and does not mutate the original value"] pub const fn copysign(self, sign: f16) -> f16 { + // SAFETY: this is actually a safe intrinsic unsafe { intrinsics::copysignf16(self, sign) } } } diff --git a/library/core/src/num/f32.rs b/library/core/src/num/f32.rs index d9337af316c..51241fa1027 100644 --- a/library/core/src/num/f32.rs +++ b/library/core/src/num/f32.rs @@ -1449,6 +1449,7 @@ impl f32 { #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")] #[inline] pub const fn abs(self) -> f32 { + // SAFETY: this is actually a safe intrinsic unsafe { intrinsics::fabsf32(self) } } @@ -1509,6 +1510,7 @@ impl f32 { #[stable(feature = "copysign", since = "1.35.0")] #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")] pub const fn copysign(self, sign: f32) -> f32 { + // SAFETY: this is actually a safe intrinsic unsafe { intrinsics::copysignf32(self, sign) } } } diff --git a/library/core/src/num/f64.rs b/library/core/src/num/f64.rs index bcab5193718..f42eaf83177 100644 --- a/library/core/src/num/f64.rs +++ b/library/core/src/num/f64.rs @@ -1449,6 +1449,7 @@ impl f64 { #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")] #[inline] pub const fn abs(self) -> f64 { + // SAFETY: this is actually a safe intrinsic unsafe { intrinsics::fabsf64(self) } } @@ -1509,6 +1510,7 @@ impl f64 { #[rustc_const_unstable(feature = "const_float_methods", issue = "130843")] #[inline] pub const fn copysign(self, sign: f64) -> f64 { + // SAFETY: this is actually a safe intrinsic unsafe { intrinsics::copysignf64(self, sign) } } }