Make some float methods unstable const fn
Some float methods are now `const fn` under the `const_float_methods` feature gate. In order to support `min`, `max`, `abs` and `copysign`, the implementation of some intrinsics had to be moved from Miri to rustc_const_eval.
This commit is contained in:
parent
b73e613e00
commit
c09ed3e767
14 changed files with 498 additions and 243 deletions
|
@ -194,8 +194,9 @@ impl f64 {
|
|||
#[rustc_allow_incoherent_impl]
|
||||
#[must_use = "method returns a new number and does not mutate the original value"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
|
||||
#[inline]
|
||||
pub fn abs(self) -> f64 {
|
||||
pub const fn abs(self) -> f64 {
|
||||
unsafe { intrinsics::fabsf64(self) }
|
||||
}
|
||||
|
||||
|
@ -218,8 +219,9 @@ impl f64 {
|
|||
#[rustc_allow_incoherent_impl]
|
||||
#[must_use = "method returns a new number and does not mutate the original value"]
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
|
||||
#[inline]
|
||||
pub fn signum(self) -> f64 {
|
||||
pub const fn signum(self) -> f64 {
|
||||
if self.is_nan() { Self::NAN } else { 1.0_f64.copysign(self) }
|
||||
}
|
||||
|
||||
|
@ -252,8 +254,9 @@ impl f64 {
|
|||
#[rustc_allow_incoherent_impl]
|
||||
#[must_use = "method returns a new number and does not mutate the original value"]
|
||||
#[stable(feature = "copysign", since = "1.35.0")]
|
||||
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
|
||||
#[inline]
|
||||
pub fn copysign(self, sign: f64) -> f64 {
|
||||
pub const fn copysign(self, sign: f64) -> f64 {
|
||||
unsafe { intrinsics::copysignf64(self, sign) }
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue