Skip to content

Commit 1128894

Browse files
committed
Stabilize const_float_classify
1 parent 27049a0 commit 1128894

File tree

5 files changed

+28
-31
lines changed

5 files changed

+28
-31
lines changed

core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,6 @@
121121
#![feature(const_cell_into_inner)]
122122
#![feature(const_eval_select)]
123123
#![feature(const_exact_div)]
124-
#![feature(const_float_classify)]
125124
#![feature(const_fmt_arguments_new)]
126125
#![feature(const_hash)]
127126
#![feature(const_heap)]

core/src/num/f128.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -288,7 +288,7 @@ impl f128 {
288288
// concerns about portability, so this implementation is for
289289
// private use internally.
290290
#[inline]
291-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
291+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
292292
pub(crate) const fn abs_private(self) -> f128 {
293293
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
294294
unsafe {
@@ -319,7 +319,7 @@ impl f128 {
319319
#[inline]
320320
#[must_use]
321321
#[unstable(feature = "f128", issue = "116909")]
322-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
322+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
323323
pub const fn is_infinite(self) -> bool {
324324
(self == f128::INFINITY) | (self == f128::NEG_INFINITY)
325325
}
@@ -346,7 +346,7 @@ impl f128 {
346346
#[inline]
347347
#[must_use]
348348
#[unstable(feature = "f128", issue = "116909")]
349-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
349+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
350350
pub const fn is_finite(self) -> bool {
351351
// There's no need to handle NaN separately: if self is NaN,
352352
// the comparison is not true, exactly as desired.
@@ -380,7 +380,7 @@ impl f128 {
380380
#[inline]
381381
#[must_use]
382382
#[unstable(feature = "f128", issue = "116909")]
383-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
383+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
384384
pub const fn is_subnormal(self) -> bool {
385385
matches!(self.classify(), FpCategory::Subnormal)
386386
}
@@ -412,7 +412,7 @@ impl f128 {
412412
#[inline]
413413
#[must_use]
414414
#[unstable(feature = "f128", issue = "116909")]
415-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
415+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
416416
pub const fn is_normal(self) -> bool {
417417
matches!(self.classify(), FpCategory::Normal)
418418
}
@@ -437,7 +437,7 @@ impl f128 {
437437
/// ```
438438
#[inline]
439439
#[unstable(feature = "f128", issue = "116909")]
440-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
440+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
441441
pub const fn classify(self) -> FpCategory {
442442
// Other float types suffer from various platform bugs that violate the usual IEEE semantics
443443
// and also make bitwise classification not always work reliably. However, `f128` cannot fit

core/src/num/f16.rs

+6-6
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,7 @@ impl f16 {
282282
// concerns about portability, so this implementation is for
283283
// private use internally.
284284
#[inline]
285-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
285+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
286286
pub(crate) const fn abs_private(self) -> f16 {
287287
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
288288
unsafe { mem::transmute::<u16, f16>(mem::transmute::<f16, u16>(self) & !Self::SIGN_MASK) }
@@ -310,7 +310,7 @@ impl f16 {
310310
#[inline]
311311
#[must_use]
312312
#[unstable(feature = "f16", issue = "116909")]
313-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
313+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
314314
pub const fn is_infinite(self) -> bool {
315315
(self == f16::INFINITY) | (self == f16::NEG_INFINITY)
316316
}
@@ -336,7 +336,7 @@ impl f16 {
336336
#[inline]
337337
#[must_use]
338338
#[unstable(feature = "f16", issue = "116909")]
339-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
339+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
340340
pub const fn is_finite(self) -> bool {
341341
// There's no need to handle NaN separately: if self is NaN,
342342
// the comparison is not true, exactly as desired.
@@ -368,7 +368,7 @@ impl f16 {
368368
#[inline]
369369
#[must_use]
370370
#[unstable(feature = "f16", issue = "116909")]
371-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
371+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
372372
pub const fn is_subnormal(self) -> bool {
373373
matches!(self.classify(), FpCategory::Subnormal)
374374
}
@@ -398,7 +398,7 @@ impl f16 {
398398
#[inline]
399399
#[must_use]
400400
#[unstable(feature = "f16", issue = "116909")]
401-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
401+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
402402
pub const fn is_normal(self) -> bool {
403403
matches!(self.classify(), FpCategory::Normal)
404404
}
@@ -422,7 +422,7 @@ impl f16 {
422422
/// ```
423423
#[inline]
424424
#[unstable(feature = "f16", issue = "116909")]
425-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
425+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
426426
pub const fn classify(self) -> FpCategory {
427427
// A previous implementation for f32/f64 tried to only use bitmask-based checks,
428428
// using `to_bits` to transmute the float to its bit repr and match on that.

core/src/num/f32.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -516,7 +516,7 @@ impl f32 {
516516
/// ```
517517
#[must_use]
518518
#[stable(feature = "rust1", since = "1.0.0")]
519-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
519+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
520520
#[inline]
521521
#[allow(clippy::eq_op)] // > if you intended to check if the operand is NaN, use `.is_nan()` instead :)
522522
pub const fn is_nan(self) -> bool {
@@ -527,7 +527,6 @@ impl f32 {
527527
// concerns about portability, so this implementation is for
528528
// private use internally.
529529
#[inline]
530-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
531530
pub(crate) const fn abs_private(self) -> f32 {
532531
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
533532
unsafe { mem::transmute::<u32, f32>(mem::transmute::<f32, u32>(self) & !Self::SIGN_MASK) }
@@ -550,7 +549,7 @@ impl f32 {
550549
/// ```
551550
#[must_use]
552551
#[stable(feature = "rust1", since = "1.0.0")]
553-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
552+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
554553
#[inline]
555554
pub const fn is_infinite(self) -> bool {
556555
// Getting clever with transmutation can result in incorrect answers on some FPUs
@@ -575,7 +574,7 @@ impl f32 {
575574
/// ```
576575
#[must_use]
577576
#[stable(feature = "rust1", since = "1.0.0")]
578-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
577+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
579578
#[inline]
580579
pub const fn is_finite(self) -> bool {
581580
// There's no need to handle NaN separately: if self is NaN,
@@ -603,7 +602,7 @@ impl f32 {
603602
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
604603
#[must_use]
605604
#[stable(feature = "is_subnormal", since = "1.53.0")]
606-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
605+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
607606
#[inline]
608607
pub const fn is_subnormal(self) -> bool {
609608
matches!(self.classify(), FpCategory::Subnormal)
@@ -630,7 +629,7 @@ impl f32 {
630629
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
631630
#[must_use]
632631
#[stable(feature = "rust1", since = "1.0.0")]
633-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
632+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
634633
#[inline]
635634
pub const fn is_normal(self) -> bool {
636635
matches!(self.classify(), FpCategory::Normal)
@@ -650,7 +649,7 @@ impl f32 {
650649
/// assert_eq!(inf.classify(), FpCategory::Infinite);
651650
/// ```
652651
#[stable(feature = "rust1", since = "1.0.0")]
653-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
652+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
654653
pub const fn classify(self) -> FpCategory {
655654
// A previous implementation tried to only use bitmask-based checks,
656655
// using f32::to_bits to transmute the float to its bit repr and match on that.
@@ -710,7 +709,7 @@ impl f32 {
710709
/// ```
711710
#[must_use]
712711
#[stable(feature = "rust1", since = "1.0.0")]
713-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
712+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
714713
#[inline]
715714
pub const fn is_sign_positive(self) -> bool {
716715
!self.is_sign_negative()
@@ -735,7 +734,7 @@ impl f32 {
735734
/// ```
736735
#[must_use]
737736
#[stable(feature = "rust1", since = "1.0.0")]
738-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
737+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
739738
#[inline]
740739
pub const fn is_sign_negative(self) -> bool {
741740
// IEEE754 says: isSignMinus(x) is true if and only if x has negative sign. isSignMinus

core/src/num/f64.rs

+8-9
Original file line numberDiff line numberDiff line change
@@ -515,7 +515,7 @@ impl f64 {
515515
/// ```
516516
#[must_use]
517517
#[stable(feature = "rust1", since = "1.0.0")]
518-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
518+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
519519
#[inline]
520520
#[allow(clippy::eq_op)] // > if you intended to check if the operand is NaN, use `.is_nan()` instead :)
521521
pub const fn is_nan(self) -> bool {
@@ -526,7 +526,6 @@ impl f64 {
526526
// concerns about portability, so this implementation is for
527527
// private use internally.
528528
#[inline]
529-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
530529
pub(crate) const fn abs_private(self) -> f64 {
531530
// SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
532531
unsafe { mem::transmute::<u64, f64>(mem::transmute::<f64, u64>(self) & !Self::SIGN_MASK) }
@@ -549,7 +548,7 @@ impl f64 {
549548
/// ```
550549
#[must_use]
551550
#[stable(feature = "rust1", since = "1.0.0")]
552-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
551+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
553552
#[inline]
554553
pub const fn is_infinite(self) -> bool {
555554
// Getting clever with transmutation can result in incorrect answers on some FPUs
@@ -574,7 +573,7 @@ impl f64 {
574573
/// ```
575574
#[must_use]
576575
#[stable(feature = "rust1", since = "1.0.0")]
577-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
576+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
578577
#[inline]
579578
pub const fn is_finite(self) -> bool {
580579
// There's no need to handle NaN separately: if self is NaN,
@@ -602,7 +601,7 @@ impl f64 {
602601
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
603602
#[must_use]
604603
#[stable(feature = "is_subnormal", since = "1.53.0")]
605-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
604+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
606605
#[inline]
607606
pub const fn is_subnormal(self) -> bool {
608607
matches!(self.classify(), FpCategory::Subnormal)
@@ -629,7 +628,7 @@ impl f64 {
629628
/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
630629
#[must_use]
631630
#[stable(feature = "rust1", since = "1.0.0")]
632-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
631+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
633632
#[inline]
634633
pub const fn is_normal(self) -> bool {
635634
matches!(self.classify(), FpCategory::Normal)
@@ -649,7 +648,7 @@ impl f64 {
649648
/// assert_eq!(inf.classify(), FpCategory::Infinite);
650649
/// ```
651650
#[stable(feature = "rust1", since = "1.0.0")]
652-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
651+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
653652
pub const fn classify(self) -> FpCategory {
654653
// A previous implementation tried to only use bitmask-based checks,
655654
// using f64::to_bits to transmute the float to its bit repr and match on that.
@@ -705,7 +704,7 @@ impl f64 {
705704
/// ```
706705
#[must_use]
707706
#[stable(feature = "rust1", since = "1.0.0")]
708-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
707+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
709708
#[inline]
710709
pub const fn is_sign_positive(self) -> bool {
711710
!self.is_sign_negative()
@@ -739,7 +738,7 @@ impl f64 {
739738
/// ```
740739
#[must_use]
741740
#[stable(feature = "rust1", since = "1.0.0")]
742-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
741+
#[rustc_const_stable(feature = "const_float_classify", since = "CURRENT_RUSTC_VERSION")]
743742
#[inline]
744743
pub const fn is_sign_negative(self) -> bool {
745744
// IEEE754 says: isSignMinus(x) is true if and only if x has negative sign. isSignMinus

0 commit comments

Comments
 (0)