Stabilize const_float_classify
· qinheping/verify-rust-std@1128894 (original) (raw)
`@@ -516,7 +516,7 @@ impl f32 {
`
516
516
```` /// ```
`517`
`517`
`#[must_use]
`
`518`
`518`
`#[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")]
`
`520`
`520`
`#[inline]
`
`521`
`521`
`` #[allow(clippy::eq_op)] // > if you intended to check if the operand is NaN, use `.is_nan()` instead :)
``
`522`
`522`
`pub const fn is_nan(self) -> bool {
`
`@@ -527,7 +527,6 @@ impl f32 {
`
`527`
`527`
`// concerns about portability, so this implementation is for
`
`528`
`528`
`// private use internally.
`
`529`
`529`
`#[inline]
`
`530`
``
`-
#[rustc_const_unstable(feature = "const_float_classify", issue = "72505")]
`
`531`
`530`
`pub(crate) const fn abs_private(self) -> f32 {
`
`532`
`531`
`` // SAFETY: This transmutation is fine just like in `to_bits`/`from_bits`.
``
`533`
`532`
`unsafe { mem::transmute::<u32, f32>(mem::transmute::<f32, u32>(self) & !Self::SIGN_MASK) }
`
`@@ -550,7 +549,7 @@ impl f32 {
`
`550`
`549`
```` /// ```
551
550
`#[must_use]
`
552
551
`#[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")]
`
554
553
`#[inline]
`
555
554
`pub const fn is_infinite(self) -> bool {
`
556
555
`// Getting clever with transmutation can result in incorrect answers on some FPUs
`
`@@ -575,7 +574,7 @@ impl f32 {
`
575
574
```` /// ```
`576`
`575`
`#[must_use]
`
`577`
`576`
`#[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")]
`
`579`
`578`
`#[inline]
`
`580`
`579`
`pub const fn is_finite(self) -> bool {
`
`581`
`580`
`// There's no need to handle NaN separately: if self is NaN,
`
`@@ -603,7 +602,7 @@ impl f32 {
`
`603`
`602`
`/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
`
`604`
`603`
`#[must_use]
`
`605`
`604`
`#[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")]
`
`607`
`606`
`#[inline]
`
`608`
`607`
`pub const fn is_subnormal(self) -> bool {
`
`609`
`608`
`matches!(self.classify(), FpCategory::Subnormal)
`
`@@ -630,7 +629,7 @@ impl f32 {
`
`630`
`629`
`/// [subnormal]: https://en.wikipedia.org/wiki/Denormal_number
`
`631`
`630`
`#[must_use]
`
`632`
`631`
`#[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")]
`
`634`
`633`
`#[inline]
`
`635`
`634`
`pub const fn is_normal(self) -> bool {
`
`636`
`635`
`matches!(self.classify(), FpCategory::Normal)
`
`@@ -650,7 +649,7 @@ impl f32 {
`
`650`
`649`
`/// assert_eq!(inf.classify(), FpCategory::Infinite);
`
`651`
`650`
```` /// ```
652
651
`#[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")]
`
654
653
`pub const fn classify(self) -> FpCategory {
`
655
654
`// A previous implementation tried to only use bitmask-based checks,
`
656
655
`// using f32::to_bits to transmute the float to its bit repr and match on that.
`
`@@ -710,7 +709,7 @@ impl f32 {
`
710
709
```` /// ```
`711`
`710`
`#[must_use]
`
`712`
`711`
`#[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")]
`
`714`
`713`
`#[inline]
`
`715`
`714`
`pub const fn is_sign_positive(self) -> bool {
`
`716`
`715`
` !self.is_sign_negative()
`
`@@ -735,7 +734,7 @@ impl f32 {
`
`735`
`734`
```` /// ```
736
735
`#[must_use]
`
737
736
`#[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")]
`
739
738
`#[inline]
`
740
739
`pub const fn is_sign_negative(self) -> bool {
`
741
740
`// IEEE754 says: isSignMinus(x) is true if and only if x has negative sign. isSignMinus
`