Skip to content

Commit 265e033

Browse files
committed
Stabilize remaining integer methods as const fn
This includes the following functions: - i*::checked_div - i*::checked_div_euclid - i*::checked_rem - i*::checked_rem_euclid - i*::div_euclid - i*::overflowing_div - i*::overflowing_div_euclid - i*::overflowing_rem - i*::overflowing_rem_euclid - i*::rem_euclid - i*::wrapping_div - i*::wrapping_div_euclid - i*::wrapping_rem - i*::wrapping_rem_euclid - u*::checked_div - u*::checked_div_euclid - u*::checked_rem - u*::checked_rem_euclid - u*::div_euclid - u*::overflowing_div - u*::overflowing_div_euclid - u*::overflowing_rem - u*::overflowing_rem_euclid - u*::rem_euclid - u*::wrapping_div - u*::wrapping_div_euclid - u*::wrapping_rem - u*::wrapping_rem_euclid
1 parent 7a9b552 commit 265e033

File tree

4 files changed

+32
-36
lines changed

4 files changed

+32
-36
lines changed

library/core/src/lib.rs

-3
Original file line numberDiff line numberDiff line change
@@ -73,11 +73,8 @@
7373
#![feature(const_discriminant)]
7474
#![feature(const_cell_into_inner)]
7575
#![feature(const_intrinsic_copy)]
76-
#![feature(const_checked_int_methods)]
77-
#![feature(const_euclidean_int_methods)]
7876
#![feature(const_float_classify)]
7977
#![feature(const_float_bits_conv)]
80-
#![feature(const_overflowing_int_methods)]
8178
#![feature(const_int_unchecked_arith)]
8279
#![feature(const_mut_refs)]
8380
#![feature(const_cttz)]

library/core/src/num/int_macros.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -513,7 +513,8 @@ macro_rules! int_impl {
513513
#[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_div(0), None);")]
514514
/// ```
515515
#[stable(feature = "rust1", since = "1.0.0")]
516-
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")]
516+
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")]
517+
#[rustc_allow_const_fn_unstable(const_int_unchecked_arith)]
517518
#[must_use = "this returns the result of the operation, \
518519
without modifying the original"]
519520
#[inline]
@@ -539,7 +540,7 @@ macro_rules! int_impl {
539540
#[doc = concat!("assert_eq!((1", stringify!($SelfT), ").checked_div_euclid(0), None);")]
540541
/// ```
541542
#[stable(feature = "euclidean_division", since = "1.38.0")]
542-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
543+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
543544
#[must_use = "this returns the result of the operation, \
544545
without modifying the original"]
545546
#[inline]
@@ -565,7 +566,8 @@ macro_rules! int_impl {
565566
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_rem(-1), None);")]
566567
/// ```
567568
#[stable(feature = "wrapping", since = "1.7.0")]
568-
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")]
569+
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")]
570+
#[rustc_allow_const_fn_unstable(const_int_unchecked_arith)]
569571
#[must_use = "this returns the result of the operation, \
570572
without modifying the original"]
571573
#[inline]
@@ -591,7 +593,7 @@ macro_rules! int_impl {
591593
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.checked_rem_euclid(-1), None);")]
592594
/// ```
593595
#[stable(feature = "euclidean_division", since = "1.38.0")]
594-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
596+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
595597
#[must_use = "this returns the result of the operation, \
596598
without modifying the original"]
597599
#[inline]
@@ -949,7 +951,7 @@ macro_rules! int_impl {
949951
/// assert_eq!((-128i8).wrapping_div(-1), -128);
950952
/// ```
951953
#[stable(feature = "num_wrapping", since = "1.2.0")]
952-
#[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")]
954+
#[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")]
953955
#[must_use = "this returns the result of the operation, \
954956
without modifying the original"]
955957
#[inline]
@@ -977,7 +979,7 @@ macro_rules! int_impl {
977979
/// assert_eq!((-128i8).wrapping_div_euclid(-1), -128);
978980
/// ```
979981
#[stable(feature = "euclidean_division", since = "1.38.0")]
980-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
982+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
981983
#[must_use = "this returns the result of the operation, \
982984
without modifying the original"]
983985
#[inline]
@@ -1005,7 +1007,7 @@ macro_rules! int_impl {
10051007
/// assert_eq!((-128i8).wrapping_rem(-1), 0);
10061008
/// ```
10071009
#[stable(feature = "num_wrapping", since = "1.2.0")]
1008-
#[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")]
1010+
#[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")]
10091011
#[must_use = "this returns the result of the operation, \
10101012
without modifying the original"]
10111013
#[inline]
@@ -1032,7 +1034,7 @@ macro_rules! int_impl {
10321034
/// assert_eq!((-128i8).wrapping_rem_euclid(-1), 0);
10331035
/// ```
10341036
#[stable(feature = "euclidean_division", since = "1.38.0")]
1035-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
1037+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
10361038
#[must_use = "this returns the result of the operation, \
10371039
without modifying the original"]
10381040
#[inline]
@@ -1299,7 +1301,7 @@ macro_rules! int_impl {
12991301
/// ```
13001302
#[inline]
13011303
#[stable(feature = "wrapping", since = "1.7.0")]
1302-
#[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")]
1304+
#[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")]
13031305
#[must_use = "this returns the result of the operation, \
13041306
without modifying the original"]
13051307
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) {
@@ -1329,7 +1331,7 @@ macro_rules! int_impl {
13291331
/// ```
13301332
#[inline]
13311333
#[stable(feature = "euclidean_division", since = "1.38.0")]
1332-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
1334+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
13331335
#[must_use = "this returns the result of the operation, \
13341336
without modifying the original"]
13351337
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) {
@@ -1360,7 +1362,7 @@ macro_rules! int_impl {
13601362
/// ```
13611363
#[inline]
13621364
#[stable(feature = "wrapping", since = "1.7.0")]
1363-
#[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")]
1365+
#[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")]
13641366
#[must_use = "this returns the result of the operation, \
13651367
without modifying the original"]
13661368
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
@@ -1390,7 +1392,7 @@ macro_rules! int_impl {
13901392
#[doc = concat!("assert_eq!(", stringify!($SelfT), "::MIN.overflowing_rem_euclid(-1), (0, true));")]
13911393
/// ```
13921394
#[stable(feature = "euclidean_division", since = "1.38.0")]
1393-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
1395+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
13941396
#[must_use = "this returns the result of the operation, \
13951397
without modifying the original"]
13961398
#[inline]
@@ -1615,7 +1617,7 @@ macro_rules! int_impl {
16151617
/// assert_eq!((-a).div_euclid(-b), 2); // -7 >= -4 * 2
16161618
/// ```
16171619
#[stable(feature = "euclidean_division", since = "1.38.0")]
1618-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
1620+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
16191621
#[must_use = "this returns the result of the operation, \
16201622
without modifying the original"]
16211623
#[inline]
@@ -1653,7 +1655,7 @@ macro_rules! int_impl {
16531655
/// assert_eq!((-a).rem_euclid(-b), 1);
16541656
/// ```
16551657
#[stable(feature = "euclidean_division", since = "1.38.0")]
1656-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
1658+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
16571659
#[must_use = "this returns the result of the operation, \
16581660
without modifying the original"]
16591661
#[inline]

library/core/src/num/uint_macros.rs

+16-14
Original file line numberDiff line numberDiff line change
@@ -522,7 +522,8 @@ macro_rules! uint_impl {
522522
#[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_div(0), None);")]
523523
/// ```
524524
#[stable(feature = "rust1", since = "1.0.0")]
525-
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")]
525+
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")]
526+
#[rustc_allow_const_fn_unstable(const_int_unchecked_arith)]
526527
#[must_use = "this returns the result of the operation, \
527528
without modifying the original"]
528529
#[inline]
@@ -548,7 +549,7 @@ macro_rules! uint_impl {
548549
#[doc = concat!("assert_eq!(1", stringify!($SelfT), ".checked_div_euclid(0), None);")]
549550
/// ```
550551
#[stable(feature = "euclidean_division", since = "1.38.0")]
551-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
552+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
552553
#[must_use = "this returns the result of the operation, \
553554
without modifying the original"]
554555
#[inline]
@@ -573,7 +574,8 @@ macro_rules! uint_impl {
573574
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem(0), None);")]
574575
/// ```
575576
#[stable(feature = "wrapping", since = "1.7.0")]
576-
#[rustc_const_unstable(feature = "const_checked_int_methods", issue = "53718")]
577+
#[rustc_const_stable(feature = "const_checked_int_methods", since = "1.51.0")]
578+
#[rustc_allow_const_fn_unstable(const_int_unchecked_arith)]
577579
#[must_use = "this returns the result of the operation, \
578580
without modifying the original"]
579581
#[inline]
@@ -599,7 +601,7 @@ macro_rules! uint_impl {
599601
#[doc = concat!("assert_eq!(5", stringify!($SelfT), ".checked_rem_euclid(0), None);")]
600602
/// ```
601603
#[stable(feature = "euclidean_division", since = "1.38.0")]
602-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
604+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
603605
#[must_use = "this returns the result of the operation, \
604606
without modifying the original"]
605607
#[inline]
@@ -876,7 +878,7 @@ macro_rules! uint_impl {
876878
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_div(10), 10);")]
877879
/// ```
878880
#[stable(feature = "num_wrapping", since = "1.2.0")]
879-
#[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")]
881+
#[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")]
880882
#[must_use = "this returns the result of the operation, \
881883
without modifying the original"]
882884
#[inline]
@@ -901,7 +903,7 @@ macro_rules! uint_impl {
901903
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_div_euclid(10), 10);")]
902904
/// ```
903905
#[stable(feature = "euclidean_division", since = "1.38.0")]
904-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
906+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
905907
#[must_use = "this returns the result of the operation, \
906908
without modifying the original"]
907909
#[inline]
@@ -924,7 +926,7 @@ macro_rules! uint_impl {
924926
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_rem(10), 0);")]
925927
/// ```
926928
#[stable(feature = "num_wrapping", since = "1.2.0")]
927-
#[rustc_const_unstable(feature = "const_wrapping_int_methods", issue = "53718")]
929+
#[rustc_const_stable(feature = "const_wrapping_int_methods", since = "1.51.0")]
928930
#[must_use = "this returns the result of the operation, \
929931
without modifying the original"]
930932
#[inline]
@@ -950,7 +952,7 @@ macro_rules! uint_impl {
950952
#[doc = concat!("assert_eq!(100", stringify!($SelfT), ".wrapping_rem_euclid(10), 0);")]
951953
/// ```
952954
#[stable(feature = "euclidean_division", since = "1.38.0")]
953-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
955+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
954956
#[must_use = "this returns the result of the operation, \
955957
without modifying the original"]
956958
#[inline]
@@ -1185,7 +1187,7 @@ macro_rules! uint_impl {
11851187
/// ```
11861188
#[inline]
11871189
#[stable(feature = "wrapping", since = "1.7.0")]
1188-
#[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")]
1190+
#[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")]
11891191
#[must_use = "this returns the result of the operation, \
11901192
without modifying the original"]
11911193
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) {
@@ -1215,7 +1217,7 @@ macro_rules! uint_impl {
12151217
/// ```
12161218
#[inline]
12171219
#[stable(feature = "euclidean_division", since = "1.38.0")]
1218-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
1220+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
12191221
#[must_use = "this returns the result of the operation, \
12201222
without modifying the original"]
12211223
pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) {
@@ -1242,7 +1244,7 @@ macro_rules! uint_impl {
12421244
/// ```
12431245
#[inline]
12441246
#[stable(feature = "wrapping", since = "1.7.0")]
1245-
#[rustc_const_unstable(feature = "const_overflowing_int_methods", issue = "53718")]
1247+
#[rustc_const_stable(feature = "const_overflowing_int_methods", since = "1.51.0")]
12461248
#[must_use = "this returns the result of the operation, \
12471249
without modifying the original"]
12481250
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
@@ -1272,7 +1274,7 @@ macro_rules! uint_impl {
12721274
/// ```
12731275
#[inline]
12741276
#[stable(feature = "euclidean_division", since = "1.38.0")]
1275-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
1277+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
12761278
#[must_use = "this returns the result of the operation, \
12771279
without modifying the original"]
12781280
pub const fn overflowing_rem_euclid(self, rhs: Self) -> (Self, bool) {
@@ -1456,7 +1458,7 @@ macro_rules! uint_impl {
14561458
#[doc = concat!("assert_eq!(7", stringify!($SelfT), ".div_euclid(4), 1); // or any other integer type")]
14571459
/// ```
14581460
#[stable(feature = "euclidean_division", since = "1.38.0")]
1459-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
1461+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
14601462
#[must_use = "this returns the result of the operation, \
14611463
without modifying the original"]
14621464
#[inline]
@@ -1484,7 +1486,7 @@ macro_rules! uint_impl {
14841486
#[doc = concat!("assert_eq!(7", stringify!($SelfT), ".rem_euclid(4), 3); // or any other integer type")]
14851487
/// ```
14861488
#[stable(feature = "euclidean_division", since = "1.38.0")]
1487-
#[rustc_const_unstable(feature = "const_euclidean_int_methods", issue = "53718")]
1489+
#[rustc_const_stable(feature = "const_euclidean_int_methods", since = "1.51.0")]
14881490
#[must_use = "this returns the result of the operation, \
14891491
without modifying the original"]
14901492
#[inline]

src/test/ui/consts/const-int-arithmetic.rs

-5
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,5 @@
11
// run-pass
22

3-
#![feature(const_checked_int_methods)]
4-
#![feature(const_euclidean_int_methods)]
5-
#![feature(const_overflowing_int_methods)]
6-
#![feature(const_wrapping_int_methods)]
7-
83
macro_rules! suite {
94
($(
105
$fn:ident -> $ty:ty { $( $label:ident : $expr:expr, $result:expr; )* }

0 commit comments

Comments
 (0)