Skip to content

Commit

Permalink
add missing safety comments
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Nov 1, 2024
1 parent 768d0cd commit ffbcba0
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 0 deletions.
1 change: 1 addition & 0 deletions core/src/num/f128.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}
1 change: 1 addition & 0 deletions core/src/num/f16.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}
}
2 changes: 2 additions & 0 deletions core/src/num/f32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}

Expand Down Expand Up @@ -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) }
}
}
2 changes: 2 additions & 0 deletions core/src/num/f64.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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) }
}

Expand Down Expand Up @@ -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) }
}
}

0 comments on commit ffbcba0

Please sign in to comment.