Skip to content

Commit 805077f

Browse files
committed
fix: gate const float round method behind const_float_round_methods
1 parent f84737e commit 805077f

File tree

7 files changed

+27
-22
lines changed

7 files changed

+27
-22
lines changed

library/core/src/num/f32.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1590,8 +1590,8 @@ pub mod math {
15901590
/// [`f32::floor`]: ../../../std/primitive.f32.html#method.floor
15911591
#[inline]
15921592
#[unstable(feature = "core_float_math", issue = "137578")]
1593+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
15931594
#[must_use = "method returns a new number and does not mutate the original value"]
1594-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
15951595
pub const fn floor(x: f32) -> f32 {
15961596
// SAFETY: intrinsic with no preconditions
15971597
unsafe { intrinsics::floorf32(x) }
@@ -1621,7 +1621,7 @@ pub mod math {
16211621
#[doc(alias = "ceiling")]
16221622
#[must_use = "method returns a new number and does not mutate the original value"]
16231623
#[unstable(feature = "core_float_math", issue = "137578")]
1624-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
1624+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
16251625
pub const fn ceil(x: f32) -> f32 {
16261626
// SAFETY: intrinsic with no preconditions
16271627
unsafe { intrinsics::ceilf32(x) }
@@ -1656,7 +1656,7 @@ pub mod math {
16561656
#[inline]
16571657
#[unstable(feature = "core_float_math", issue = "137578")]
16581658
#[must_use = "method returns a new number and does not mutate the original value"]
1659-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
1659+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
16601660
pub const fn round(x: f32) -> f32 {
16611661
// SAFETY: intrinsic with no preconditions
16621662
unsafe { intrinsics::roundf32(x) }
@@ -1690,7 +1690,7 @@ pub mod math {
16901690
#[inline]
16911691
#[unstable(feature = "core_float_math", issue = "137578")]
16921692
#[must_use = "method returns a new number and does not mutate the original value"]
1693-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
1693+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
16941694
pub const fn round_ties_even(x: f32) -> f32 {
16951695
intrinsics::round_ties_even_f32(x)
16961696
}
@@ -1721,7 +1721,7 @@ pub mod math {
17211721
#[doc(alias = "truncate")]
17221722
#[must_use = "method returns a new number and does not mutate the original value"]
17231723
#[unstable(feature = "core_float_math", issue = "137578")]
1724-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
1724+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
17251725
pub const fn trunc(x: f32) -> f32 {
17261726
// SAFETY: intrinsic with no preconditions
17271727
unsafe { intrinsics::truncf32(x) }
@@ -1751,6 +1751,7 @@ pub mod math {
17511751
/// [`f32::fract`]: ../../../std/primitive.f32.html#method.fract
17521752
#[inline]
17531753
#[unstable(feature = "core_float_math", issue = "137578")]
1754+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
17541755
#[must_use = "method returns a new number and does not mutate the original value"]
17551756
pub const fn fract(x: f32) -> f32 {
17561757
x - trunc(x)

library/core/src/num/f64.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1589,8 +1589,8 @@ pub mod math {
15891589
/// [`f64::floor`]: ../../../std/primitive.f64.html#method.floor
15901590
#[inline]
15911591
#[unstable(feature = "core_float_math", issue = "137578")]
1592+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
15921593
#[must_use = "method returns a new number and does not mutate the original value"]
1593-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
15941594
pub const fn floor(x: f64) -> f64 {
15951595
// SAFETY: intrinsic with no preconditions
15961596
unsafe { intrinsics::floorf64(x) }
@@ -1619,8 +1619,8 @@ pub mod math {
16191619
#[inline]
16201620
#[doc(alias = "ceiling")]
16211621
#[unstable(feature = "core_float_math", issue = "137578")]
1622+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
16221623
#[must_use = "method returns a new number and does not mutate the original value"]
1623-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
16241624
pub const fn ceil(x: f64) -> f64 {
16251625
// SAFETY: intrinsic with no preconditions
16261626
unsafe { intrinsics::ceilf64(x) }
@@ -1654,8 +1654,8 @@ pub mod math {
16541654
/// [`f64::round`]: ../../../std/primitive.f64.html#method.round
16551655
#[inline]
16561656
#[unstable(feature = "core_float_math", issue = "137578")]
1657+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
16571658
#[must_use = "method returns a new number and does not mutate the original value"]
1658-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
16591659
pub const fn round(x: f64) -> f64 {
16601660
// SAFETY: intrinsic with no preconditions
16611661
unsafe { intrinsics::roundf64(x) }
@@ -1688,8 +1688,8 @@ pub mod math {
16881688
/// [`f64::round_ties_even`]: ../../../std/primitive.f64.html#method.round_ties_even
16891689
#[inline]
16901690
#[unstable(feature = "core_float_math", issue = "137578")]
1691+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
16911692
#[must_use = "method returns a new number and does not mutate the original value"]
1692-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
16931693
pub const fn round_ties_even(x: f64) -> f64 {
16941694
intrinsics::round_ties_even_f64(x)
16951695
}
@@ -1719,8 +1719,8 @@ pub mod math {
17191719
#[inline]
17201720
#[doc(alias = "truncate")]
17211721
#[unstable(feature = "core_float_math", issue = "137578")]
1722+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
17221723
#[must_use = "method returns a new number and does not mutate the original value"]
1723-
#[rustc_allow_const_fn_unstable(core_intrinsics)]
17241724
pub const fn trunc(x: f64) -> f64 {
17251725
// SAFETY: intrinsic with no preconditions
17261726
unsafe { intrinsics::truncf64(x) }
@@ -1750,6 +1750,7 @@ pub mod math {
17501750
/// [`f64::fract`]: ../../../std/primitive.f64.html#method.fract
17511751
#[inline]
17521752
#[unstable(feature = "core_float_math", issue = "137578")]
1753+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
17531754
#[must_use = "method returns a new number and does not mutate the original value"]
17541755
pub const fn fract(x: f64) -> f64 {
17551756
x - trunc(x)

library/coretests/tests/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#![feature(clone_to_uninit)]
1818
#![feature(const_eval_select)]
1919
#![feature(const_float_methods)]
20+
#![feature(const_float_round_methods)]
2021
#![feature(const_trait_impl)]
2122
#![feature(core_float_math)]
2223
#![feature(core_intrinsics)]

library/std/src/f32.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl f32 {
4444
#[rustc_allow_incoherent_impl]
4545
#[must_use = "method returns a new number and does not mutate the original value"]
4646
#[stable(feature = "rust1", since = "1.0.0")]
47-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
47+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
4848
#[inline]
4949
pub const fn floor(self) -> f32 {
5050
core::f32::math::floor(self)
@@ -67,7 +67,7 @@ impl f32 {
6767
#[rustc_allow_incoherent_impl]
6868
#[must_use = "method returns a new number and does not mutate the original value"]
6969
#[stable(feature = "rust1", since = "1.0.0")]
70-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
70+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
7171
#[inline]
7272
pub const fn ceil(self) -> f32 {
7373
core::f32::math::ceil(self)
@@ -96,7 +96,7 @@ impl f32 {
9696
#[rustc_allow_incoherent_impl]
9797
#[must_use = "method returns a new number and does not mutate the original value"]
9898
#[stable(feature = "rust1", since = "1.0.0")]
99-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
99+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
100100
#[inline]
101101
pub const fn round(self) -> f32 {
102102
core::f32::math::round(self)
@@ -123,7 +123,7 @@ impl f32 {
123123
#[rustc_allow_incoherent_impl]
124124
#[must_use = "method returns a new number and does not mutate the original value"]
125125
#[stable(feature = "round_ties_even", since = "1.77.0")]
126-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
126+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
127127
#[inline]
128128
pub const fn round_ties_even(self) -> f32 {
129129
core::f32::math::round_ties_even(self)
@@ -149,7 +149,7 @@ impl f32 {
149149
#[rustc_allow_incoherent_impl]
150150
#[must_use = "method returns a new number and does not mutate the original value"]
151151
#[stable(feature = "rust1", since = "1.0.0")]
152-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
152+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
153153
#[inline]
154154
pub const fn trunc(self) -> f32 {
155155
core::f32::math::trunc(self)
@@ -173,7 +173,7 @@ impl f32 {
173173
#[rustc_allow_incoherent_impl]
174174
#[must_use = "method returns a new number and does not mutate the original value"]
175175
#[stable(feature = "rust1", since = "1.0.0")]
176-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
176+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
177177
#[inline]
178178
pub const fn fract(self) -> f32 {
179179
core::f32::math::fract(self)

library/std/src/f64.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ impl f64 {
4444
#[rustc_allow_incoherent_impl]
4545
#[must_use = "method returns a new number and does not mutate the original value"]
4646
#[stable(feature = "rust1", since = "1.0.0")]
47-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
47+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
4848
#[inline]
4949
pub const fn floor(self) -> f64 {
5050
core::f64::math::floor(self)
@@ -67,7 +67,7 @@ impl f64 {
6767
#[rustc_allow_incoherent_impl]
6868
#[must_use = "method returns a new number and does not mutate the original value"]
6969
#[stable(feature = "rust1", since = "1.0.0")]
70-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
70+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
7171
#[inline]
7272
pub const fn ceil(self) -> f64 {
7373
core::f64::math::ceil(self)
@@ -96,7 +96,7 @@ impl f64 {
9696
#[rustc_allow_incoherent_impl]
9797
#[must_use = "method returns a new number and does not mutate the original value"]
9898
#[stable(feature = "rust1", since = "1.0.0")]
99-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
99+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
100100
#[inline]
101101
pub const fn round(self) -> f64 {
102102
core::f64::math::round(self)
@@ -123,7 +123,7 @@ impl f64 {
123123
#[rustc_allow_incoherent_impl]
124124
#[must_use = "method returns a new number and does not mutate the original value"]
125125
#[stable(feature = "round_ties_even", since = "1.77.0")]
126-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
126+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
127127
#[inline]
128128
pub const fn round_ties_even(self) -> f64 {
129129
core::f64::math::round_ties_even(self)
@@ -149,7 +149,7 @@ impl f64 {
149149
#[rustc_allow_incoherent_impl]
150150
#[must_use = "method returns a new number and does not mutate the original value"]
151151
#[stable(feature = "rust1", since = "1.0.0")]
152-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
152+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
153153
#[inline]
154154
pub const fn trunc(self) -> f64 {
155155
core::f64::math::trunc(self)
@@ -173,7 +173,7 @@ impl f64 {
173173
#[rustc_allow_incoherent_impl]
174174
#[must_use = "method returns a new number and does not mutate the original value"]
175175
#[stable(feature = "rust1", since = "1.0.0")]
176-
#[rustc_const_unstable(feature = "const_float_methods", issue = "130843")]
176+
#[rustc_const_unstable(feature = "const_float_round_methods", issue = "141555")]
177177
#[inline]
178178
pub const fn fract(self) -> f64 {
179179
core::f64::math::fract(self)

library/std/src/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -335,6 +335,7 @@
335335
#![feature(bstr_internals)]
336336
#![feature(char_internals)]
337337
#![feature(clone_to_uninit)]
338+
#![feature(const_float_round_methods)]
338339
#![feature(core_intrinsics)]
339340
#![feature(core_io_borrowed_buf)]
340341
#![feature(duration_constants)]

tests/ui/consts/const-eval/float_methods.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
44
#![feature(f16, f128)]
55
#![feature(const_float_methods)]
6+
#![feature(const_float_round_methods)]
67

78
const F16_MIN: f16 = 1.0_f16.min(0.5_f16);
89
const F16_MAX: f16 = 1.0_f16.max(0.5_f16);

0 commit comments

Comments
 (0)