Skip to content

Commit a461cf9

Browse files
committed
remove no-longer-needed abs_private
1 parent 2e24b7f commit a461cf9

File tree

5 files changed

+17
-51
lines changed

5 files changed

+17
-51
lines changed

core/src/fmt/float.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ macro_rules! impl_general_format {
1313
($($t:ident)*) => {
1414
$(impl GeneralFormat for $t {
1515
fn already_rounded_value_should_use_exponential(&self) -> bool {
16-
let abs = $t::abs_private(*self);
16+
let abs = $t::abs(*self);
1717
(abs != 0.0 && abs < 1e-4) || abs >= 1e+16
1818
}
1919
})*

core/src/num/f128.rs

+4-14
Original file line numberDiff line numberDiff line change
@@ -284,17 +284,6 @@ impl f128 {
284284
self != self
285285
}
286286

287-
// FIXME(#50145): `abs` is publicly unavailable in core due to
288-
// concerns about portability, so this implementation is for
289-
// private use internally.
290-
#[inline]
291-
pub(crate) const fn abs_private(self) -> f128 {
292-
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
293-
unsafe {
294-
mem::transmute::<u128, f128>(mem::transmute::<f128, u128>(self) & !Self::SIGN_MASK)
295-
}
296-
}
297-
298287
/// Returns `true` if this value is positive infinity or negative infinity, and
299288
/// `false` otherwise.
300289
///
@@ -344,10 +333,11 @@ impl f128 {
344333
#[inline]
345334
#[must_use]
346335
#[unstable(feature = "f128", issue = "116909")]
336+
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
347337
pub const fn is_finite(self) -> bool {
348338
// There's no need to handle NaN separately: if self is NaN,
349339
// the comparison is not true, exactly as desired.
350-
self.abs_private() < Self::INFINITY
340+
self.abs() < Self::INFINITY
351341
}
352342

353343
/// Returns `true` if the number is [subnormal].
@@ -835,8 +825,8 @@ impl f128 {
835825
const HI: f128 = f128::MAX / 2.;
836826

837827
let (a, b) = (self, other);
838-
let abs_a = a.abs_private();
839-
let abs_b = b.abs_private();
828+
let abs_a = a.abs();
829+
let abs_b = b.abs();
840830

841831
if abs_a <= HI && abs_b <= HI {
842832
// Overflow is impossible

core/src/num/f16.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -278,15 +278,6 @@ impl f16 {
278278
self != self
279279
}
280280

281-
// FIXMxE(#50145): `abs` is publicly unavailable in core due to
282-
// concerns about portability, so this implementation is for
283-
// private use internally.
284-
#[inline]
285-
pub(crate) const fn abs_private(self) -> f16 {
286-
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
287-
unsafe { mem::transmute::<u16, f16>(mem::transmute::<f16, u16>(self) & !Self::SIGN_MASK) }
288-
}
289-
290281
/// Returns `true` if this value is positive infinity or negative infinity, and
291282
/// `false` otherwise.
292283
///
@@ -334,10 +325,11 @@ impl f16 {
334325
#[inline]
335326
#[must_use]
336327
#[unstable(feature = "f16", issue = "116909")]
328+
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
337329
pub const fn is_finite(self) -> bool {
338330
// There's no need to handle NaN separately: if self is NaN,
339331
// the comparison is not true, exactly as desired.
340-
self.abs_private() < Self::INFINITY
332+
self.abs() < Self::INFINITY
341333
}
342334

343335
/// Returns `true` if the number is [subnormal].
@@ -820,8 +812,8 @@ impl f16 {
820812
const HI: f16 = f16::MAX / 2.;
821813

822814
let (a, b) = (self, other);
823-
let abs_a = a.abs_private();
824-
let abs_b = b.abs_private();
815+
let abs_a = a.abs();
816+
let abs_b = b.abs();
825817

826818
if abs_a <= HI && abs_b <= HI {
827819
// Overflow is impossible

core/src/num/f32.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -524,15 +524,6 @@ impl f32 {
524524
self != self
525525
}
526526

527-
// FIXME(#50145): `abs` is publicly unavailable in core due to
528-
// concerns about portability, so this implementation is for
529-
// private use internally.
530-
#[inline]
531-
pub(crate) const fn abs_private(self) -> f32 {
532-
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
533-
unsafe { mem::transmute::<u32, f32>(mem::transmute::<f32, u32>(self) & !Self::SIGN_MASK) }
534-
}
535-
536527
/// Returns `true` if this value is positive infinity or negative infinity, and
537528
/// `false` otherwise.
538529
///
@@ -577,10 +568,11 @@ impl f32 {
577568
#[stable(feature = "rust1", since = "1.0.0")]
578569
#[rustc_const_stable(feature = "const_float_classify", since = "1.83.0")]
579570
#[inline]
571+
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
580572
pub const fn is_finite(self) -> bool {
581573
// There's no need to handle NaN separately: if self is NaN,
582574
// the comparison is not true, exactly as desired.
583-
self.abs_private() < Self::INFINITY
575+
self.abs() < Self::INFINITY
584576
}
585577

586578
/// Returns `true` if the number is [subnormal].
@@ -1020,8 +1012,8 @@ impl f32 {
10201012
const HI: f32 = f32::MAX / 2.;
10211013

10221014
let (a, b) = (self, other);
1023-
let abs_a = a.abs_private();
1024-
let abs_b = b.abs_private();
1015+
let abs_a = a.abs();
1016+
let abs_b = b.abs();
10251017

10261018
if abs_a <= HI && abs_b <= HI {
10271019
// Overflow is impossible

core/src/num/f64.rs

+4-12
Original file line numberDiff line numberDiff line change
@@ -523,15 +523,6 @@ impl f64 {
523523
self != self
524524
}
525525

526-
// FIXME(#50145): `abs` is publicly unavailable in core due to
527-
// concerns about portability, so this implementation is for
528-
// private use internally.
529-
#[inline]
530-
pub(crate) const fn abs_private(self) -> f64 {
531-
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
532-
unsafe { mem::transmute::<u64, f64>(mem::transmute::<f64, u64>(self) & !Self::SIGN_MASK) }
533-
}
534-
535526
/// Returns `true` if this value is positive infinity or negative infinity, and
536527
/// `false` otherwise.
537528
///
@@ -576,10 +567,11 @@ impl f64 {
576567
#[stable(feature = "rust1", since = "1.0.0")]
577568
#[rustc_const_stable(feature = "const_float_classify", since = "1.83.0")]
578569
#[inline]
570+
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
579571
pub const fn is_finite(self) -> bool {
580572
// There's no need to handle NaN separately: if self is NaN,
581573
// the comparison is not true, exactly as desired.
582-
self.abs_private() < Self::INFINITY
574+
self.abs() < Self::INFINITY
583575
}
584576

585577
/// Returns `true` if the number is [subnormal].
@@ -1023,8 +1015,8 @@ impl f64 {
10231015
const HI: f64 = f64::MAX / 2.;
10241016

10251017
let (a, b) = (self, other);
1026-
let abs_a = a.abs_private();
1027-
let abs_b = b.abs_private();
1018+
let abs_a = a.abs();
1019+
let abs_b = b.abs();
10281020

10291021
if abs_a <= HI && abs_b <= HI {
10301022
// Overflow is impossible

0 commit comments

Comments
 (0)