Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 641c1ae

Browse files
committedNov 23, 2024
Stabilize const_float_methods
1 parent a12c838 commit 641c1ae

File tree

7 files changed

+70
-50
lines changed

7 files changed

+70
-50
lines changed
 

‎core/src/intrinsics/mod.rs

+40-8
Original file line numberDiff line numberDiff line change
@@ -4267,7 +4267,11 @@ pub const fn minnumf16(_x: f16, _y: f16) -> f16 {
42674267
/// The stabilized version of this intrinsic is
42684268
/// [`f32::min`]
42694269
#[rustc_nounwind]
4270-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4270+
#[cfg_attr(
4271+
bootstrap,
4272+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4273+
)]
4274+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
42714275
#[rustc_intrinsic]
42724276
#[rustc_intrinsic_must_be_overridden]
42734277
pub const fn minnumf32(_x: f32, _y: f32) -> f32 {
@@ -4284,7 +4288,11 @@ pub const fn minnumf32(_x: f32, _y: f32) -> f32 {
42844288
/// The stabilized version of this intrinsic is
42854289
/// [`f64::min`]
42864290
#[rustc_nounwind]
4287-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4291+
#[cfg_attr(
4292+
bootstrap,
4293+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4294+
)]
4295+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
42884296
#[rustc_intrinsic]
42894297
#[rustc_intrinsic_must_be_overridden]
42904298
pub const fn minnumf64(_x: f64, _y: f64) -> f64 {
@@ -4335,7 +4343,11 @@ pub const fn maxnumf16(_x: f16, _y: f16) -> f16 {
43354343
/// The stabilized version of this intrinsic is
43364344
/// [`f32::max`]
43374345
#[rustc_nounwind]
4338-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4346+
#[cfg_attr(
4347+
bootstrap,
4348+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4349+
)]
4350+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
43394351
#[rustc_intrinsic]
43404352
#[rustc_intrinsic_must_be_overridden]
43414353
pub const fn maxnumf32(_x: f32, _y: f32) -> f32 {
@@ -4352,7 +4364,11 @@ pub const fn maxnumf32(_x: f32, _y: f32) -> f32 {
43524364
/// The stabilized version of this intrinsic is
43534365
/// [`f64::max`]
43544366
#[rustc_nounwind]
4355-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4367+
#[cfg_attr(
4368+
bootstrap,
4369+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4370+
)]
4371+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
43564372
#[rustc_intrinsic]
43574373
#[rustc_intrinsic_must_be_overridden]
43584374
pub const fn maxnumf64(_x: f64, _y: f64) -> f64 {
@@ -4393,7 +4409,11 @@ pub const unsafe fn fabsf16(_x: f16) -> f16 {
43934409
/// The stabilized version of this intrinsic is
43944410
/// [`f32::abs`](../../std/primitive.f32.html#method.abs)
43954411
#[rustc_nounwind]
4396-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4412+
#[cfg_attr(
4413+
bootstrap,
4414+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4415+
)]
4416+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
43974417
#[rustc_intrinsic]
43984418
#[rustc_intrinsic_must_be_overridden]
43994419
pub const unsafe fn fabsf32(_x: f32) -> f32 {
@@ -4405,7 +4425,11 @@ pub const unsafe fn fabsf32(_x: f32) -> f32 {
44054425
/// The stabilized version of this intrinsic is
44064426
/// [`f64::abs`](../../std/primitive.f64.html#method.abs)
44074427
#[rustc_nounwind]
4408-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4428+
#[cfg_attr(
4429+
bootstrap,
4430+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4431+
)]
4432+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
44094433
#[rustc_intrinsic]
44104434
#[rustc_intrinsic_must_be_overridden]
44114435
pub const unsafe fn fabsf64(_x: f64) -> f64 {
@@ -4441,7 +4465,11 @@ pub const unsafe fn copysignf16(_x: f16, _y: f16) -> f16 {
44414465
/// The stabilized version of this intrinsic is
44424466
/// [`f32::copysign`](../../std/primitive.f32.html#method.copysign)
44434467
#[rustc_nounwind]
4444-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4468+
#[cfg_attr(
4469+
bootstrap,
4470+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4471+
)]
4472+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
44454473
#[rustc_intrinsic]
44464474
#[rustc_intrinsic_must_be_overridden]
44474475
pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32 {
@@ -4452,7 +4480,11 @@ pub const unsafe fn copysignf32(_x: f32, _y: f32) -> f32 {
44524480
/// The stabilized version of this intrinsic is
44534481
/// [`f64::copysign`](../../std/primitive.f64.html#method.copysign)
44544482
#[rustc_nounwind]
4455-
#[cfg_attr(bootstrap, rustc_const_unstable(feature = "const_float_methods", issue = "130843"))]
4483+
#[cfg_attr(
4484+
bootstrap,
4485+
rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")
4486+
)]
4487+
#[cfg_attr(not(bootstrap), rustc_intrinsic_const_stable_indirect)]
44564488
#[rustc_intrinsic]
44574489
#[rustc_intrinsic_must_be_overridden]
44584490
pub const unsafe fn copysignf64(_x: f64, _y: f64) -> f64 {

‎core/src/lib.rs

-1
Original file line numberDiff line numberDiff line change
@@ -118,7 +118,6 @@
118118
#![feature(const_black_box)]
119119
#![feature(const_eq_ignore_ascii_case)]
120120
#![feature(const_eval_select)]
121-
#![feature(const_float_methods)]
122121
#![feature(const_heap)]
123122
#![feature(const_nonnull_new)]
124123
#![feature(const_ptr_sub_ptr)]

‎core/src/num/f128.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -334,7 +334,7 @@ impl f128 {
334334
#[inline]
335335
#[must_use]
336336
#[unstable(feature = "f128", issue = "116909")]
337-
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
337+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
338338
pub const fn is_finite(self) -> bool {
339339
// There's no need to handle NaN separately: if self is NaN,
340340
// the comparison is not true, exactly as desired.
@@ -612,7 +612,6 @@ impl f128 {
612612
/// ```
613613
#[inline]
614614
#[unstable(feature = "f128", issue = "116909")]
615-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
616615
#[must_use = "this returns the result of the operation, without modifying the original"]
617616
pub const fn recip(self) -> Self {
618617
1.0 / self
@@ -633,7 +632,6 @@ impl f128 {
633632
/// ```
634633
#[inline]
635634
#[unstable(feature = "f128", issue = "116909")]
636-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
637635
#[must_use = "this returns the result of the operation, without modifying the original"]
638636
pub const fn to_degrees(self) -> Self {
639637
// Use a literal for better precision.
@@ -657,7 +655,6 @@ impl f128 {
657655
/// ```
658656
#[inline]
659657
#[unstable(feature = "f128", issue = "116909")]
660-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
661658
#[must_use = "this returns the result of the operation, without modifying the original"]
662659
pub const fn to_radians(self) -> f128 {
663660
// Use a literal for better precision.
@@ -686,7 +683,7 @@ impl f128 {
686683
/// ```
687684
#[inline]
688685
#[unstable(feature = "f128", issue = "116909")]
689-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
686+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
690687
#[must_use = "this returns the result of the comparison, without modifying either input"]
691688
pub const fn max(self, other: f128) -> f128 {
692689
intrinsics::maxnumf128(self, other)
@@ -712,7 +709,7 @@ impl f128 {
712709
/// ```
713710
#[inline]
714711
#[unstable(feature = "f128", issue = "116909")]
715-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
712+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
716713
#[must_use = "this returns the result of the comparison, without modifying either input"]
717714
pub const fn min(self, other: f128) -> f128 {
718715
intrinsics::minnumf128(self, other)
@@ -1251,7 +1248,6 @@ impl f128 {
12511248
/// ```
12521249
#[inline]
12531250
#[unstable(feature = "f128", issue = "116909")]
1254-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
12551251
#[must_use = "method returns a new number and does not mutate the original value"]
12561252
pub const fn clamp(mut self, min: f128, max: f128) -> f128 {
12571253
const_assert!(
@@ -1292,7 +1288,7 @@ impl f128 {
12921288
/// ```
12931289
#[inline]
12941290
#[unstable(feature = "f128", issue = "116909")]
1295-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1291+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
12961292
#[must_use = "method returns a new number and does not mutate the original value"]
12971293
pub const fn abs(self) -> Self {
12981294
// FIXME(f16_f128): replace with `intrinsics::fabsf128` when available
@@ -1322,7 +1318,7 @@ impl f128 {
13221318
/// ```
13231319
#[inline]
13241320
#[unstable(feature = "f128", issue = "116909")]
1325-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1321+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
13261322
#[must_use = "method returns a new number and does not mutate the original value"]
13271323
pub const fn signum(self) -> f128 {
13281324
if self.is_nan() { Self::NAN } else { 1.0_f128.copysign(self) }
@@ -1360,7 +1356,7 @@ impl f128 {
13601356
/// ```
13611357
#[inline]
13621358
#[unstable(feature = "f128", issue = "116909")]
1363-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1359+
#[rustc_const_unstable(feature = "f128", issue = "116909")]
13641360
#[must_use = "method returns a new number and does not mutate the original value"]
13651361
pub const fn copysign(self, sign: f128) -> f128 {
13661362
// SAFETY: this is actually a safe intrinsic

‎core/src/num/f16.rs

+6-10
Original file line numberDiff line numberDiff line change
@@ -326,7 +326,7 @@ impl f16 {
326326
#[inline]
327327
#[must_use]
328328
#[unstable(feature = "f16", issue = "116909")]
329-
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
329+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
330330
pub const fn is_finite(self) -> bool {
331331
// There's no need to handle NaN separately: if self is NaN,
332332
// the comparison is not true, exactly as desired.
@@ -605,7 +605,6 @@ impl f16 {
605605
/// ```
606606
#[inline]
607607
#[unstable(feature = "f16", issue = "116909")]
608-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
609608
#[must_use = "this returns the result of the operation, without modifying the original"]
610609
pub const fn recip(self) -> Self {
611610
1.0 / self
@@ -626,7 +625,6 @@ impl f16 {
626625
/// ```
627626
#[inline]
628627
#[unstable(feature = "f16", issue = "116909")]
629-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
630628
#[must_use = "this returns the result of the operation, without modifying the original"]
631629
pub const fn to_degrees(self) -> Self {
632630
// Use a literal for better precision.
@@ -650,7 +648,6 @@ impl f16 {
650648
/// ```
651649
#[inline]
652650
#[unstable(feature = "f16", issue = "116909")]
653-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
654651
#[must_use = "this returns the result of the operation, without modifying the original"]
655652
pub const fn to_radians(self) -> f16 {
656653
// Use a literal for better precision.
@@ -677,7 +674,7 @@ impl f16 {
677674
/// ```
678675
#[inline]
679676
#[unstable(feature = "f16", issue = "116909")]
680-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
677+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
681678
#[must_use = "this returns the result of the comparison, without modifying either input"]
682679
pub const fn max(self, other: f16) -> f16 {
683680
intrinsics::maxnumf16(self, other)
@@ -702,7 +699,7 @@ impl f16 {
702699
/// ```
703700
#[inline]
704701
#[unstable(feature = "f16", issue = "116909")]
705-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
702+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
706703
#[must_use = "this returns the result of the comparison, without modifying either input"]
707704
pub const fn min(self, other: f16) -> f16 {
708705
intrinsics::minnumf16(self, other)
@@ -1228,7 +1225,6 @@ impl f16 {
12281225
/// ```
12291226
#[inline]
12301227
#[unstable(feature = "f16", issue = "116909")]
1231-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
12321228
#[must_use = "method returns a new number and does not mutate the original value"]
12331229
pub const fn clamp(mut self, min: f16, max: f16) -> f16 {
12341230
const_assert!(
@@ -1269,7 +1265,7 @@ impl f16 {
12691265
/// ```
12701266
#[inline]
12711267
#[unstable(feature = "f16", issue = "116909")]
1272-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1268+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
12731269
#[must_use = "method returns a new number and does not mutate the original value"]
12741270
pub const fn abs(self) -> Self {
12751271
// FIXME(f16_f128): replace with `intrinsics::fabsf16` when available
@@ -1298,7 +1294,7 @@ impl f16 {
12981294
/// ```
12991295
#[inline]
13001296
#[unstable(feature = "f16", issue = "116909")]
1301-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1297+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
13021298
#[must_use = "method returns a new number and does not mutate the original value"]
13031299
pub const fn signum(self) -> f16 {
13041300
if self.is_nan() { Self::NAN } else { 1.0_f16.copysign(self) }
@@ -1336,7 +1332,7 @@ impl f16 {
13361332
/// ```
13371333
#[inline]
13381334
#[unstable(feature = "f16", issue = "116909")]
1339-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1335+
#[rustc_const_unstable(feature = "f16", issue = "116909")]
13401336
#[must_use = "method returns a new number and does not mutate the original value"]
13411337
pub const fn copysign(self, sign: f16) -> f16 {
13421338
// SAFETY: this is actually a safe intrinsic

‎core/src/num/f32.rs

+9-10
Original file line numberDiff line numberDiff line change
@@ -569,7 +569,6 @@ impl f32 {
569569
#[stable(feature = "rust1", since = "1.0.0")]
570570
#[rustc_const_stable(feature = "const_float_classify", since = "1.83.0")]
571571
#[inline]
572-
#[rustc_allow_const_fn_unstable(const_float_methods)] // for `abs`
573572
pub const fn is_finite(self) -> bool {
574573
// There's no need to handle NaN separately: if self is NaN,
575574
// the comparison is not true, exactly as desired.
@@ -819,7 +818,7 @@ impl f32 {
819818
/// ```
820819
#[must_use = "this returns the result of the operation, without modifying the original"]
821820
#[stable(feature = "rust1", since = "1.0.0")]
822-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
821+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
823822
#[inline]
824823
pub const fn recip(self) -> f32 {
825824
1.0 / self
@@ -837,7 +836,7 @@ impl f32 {
837836
#[must_use = "this returns the result of the operation, \
838837
without modifying the original"]
839838
#[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")]
840-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
839+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
841840
#[inline]
842841
pub const fn to_degrees(self) -> f32 {
843842
// Use a constant for better precision.
@@ -857,7 +856,7 @@ impl f32 {
857856
#[must_use = "this returns the result of the operation, \
858857
without modifying the original"]
859858
#[stable(feature = "f32_deg_rad_conversions", since = "1.7.0")]
860-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
859+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
861860
#[inline]
862861
pub const fn to_radians(self) -> f32 {
863862
const RADS_PER_DEG: f32 = consts::PI / 180.0;
@@ -879,7 +878,7 @@ impl f32 {
879878
/// ```
880879
#[must_use = "this returns the result of the comparison, without modifying either input"]
881880
#[stable(feature = "rust1", since = "1.0.0")]
882-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
881+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
883882
#[inline]
884883
pub const fn max(self, other: f32) -> f32 {
885884
intrinsics::maxnumf32(self, other)
@@ -900,7 +899,7 @@ impl f32 {
900899
/// ```
901900
#[must_use = "this returns the result of the comparison, without modifying either input"]
902901
#[stable(feature = "rust1", since = "1.0.0")]
903-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
902+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
904903
#[inline]
905904
pub const fn min(self, other: f32) -> f32 {
906905
intrinsics::minnumf32(self, other)
@@ -1397,7 +1396,7 @@ impl f32 {
13971396
/// ```
13981397
#[must_use = "method returns a new number and does not mutate the original value"]
13991398
#[stable(feature = "clamp", since = "1.50.0")]
1400-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1399+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14011400
#[inline]
14021401
pub const fn clamp(mut self, min: f32, max: f32) -> f32 {
14031402
const_assert!(
@@ -1434,7 +1433,7 @@ impl f32 {
14341433
/// ```
14351434
#[must_use = "method returns a new number and does not mutate the original value"]
14361435
#[stable(feature = "rust1", since = "1.0.0")]
1437-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1436+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14381437
#[inline]
14391438
pub const fn abs(self) -> f32 {
14401439
// SAFETY: this is actually a safe intrinsic
@@ -1459,7 +1458,7 @@ impl f32 {
14591458
/// ```
14601459
#[must_use = "method returns a new number and does not mutate the original value"]
14611460
#[stable(feature = "rust1", since = "1.0.0")]
1462-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1461+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14631462
#[inline]
14641463
pub const fn signum(self) -> f32 {
14651464
if self.is_nan() { Self::NAN } else { 1.0_f32.copysign(self) }
@@ -1494,7 +1493,7 @@ impl f32 {
14941493
#[must_use = "method returns a new number and does not mutate the original value"]
14951494
#[inline]
14961495
#[stable(feature = "copysign", since = "1.35.0")]
1497-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
1496+
#[rustc_const_stable(feature = "const_float_methods", since = "CURRENT_RUSTC_VERSION")]
14981497
pub const fn copysign(self, sign: f32) -> f32 {
14991498
// SAFETY: this is actually a safe intrinsic
15001499
unsafe { intrinsics::copysignf32(self, sign) }
There was a problem loading the remainder of the diff.

0 commit comments

Comments
 (0)
Failed to load comments.