Skip to content

Commit de52a54

Browse files
Make overflowing arithmetic const
Co-Authored-By: 9999years <rbt@sent.as>
1 parent 37c1418 commit de52a54

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

src/libcore/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,7 @@
7474
#![feature(const_if_match)]
7575
#![feature(const_int_checked)]
7676
#![feature(const_int_euclidean)]
77+
#![feature(const_int_overflowing)]
7778
#![feature(const_panic)]
7879
#![feature(const_fn_union)]
7980
#![feature(const_generics)]

src/libcore/num/mod.rs

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,9 +1646,10 @@ $EndFeature, "
16461646
```"),
16471647
#[inline]
16481648
#[stable(feature = "wrapping", since = "1.7.0")]
1649+
#[rustc_const_unstable(feature = "const_int_overflowing", issue = "53718")]
16491650
#[must_use = "this returns the result of the operation, \
16501651
without modifying the original"]
1651-
pub fn overflowing_div(self, rhs: Self) -> (Self, bool) {
1652+
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) {
16521653
if self == Self::min_value() && rhs == -1 {
16531654
(self, true)
16541655
} else {
@@ -1715,9 +1716,10 @@ $EndFeature, "
17151716
```"),
17161717
#[inline]
17171718
#[stable(feature = "wrapping", since = "1.7.0")]
1719+
#[rustc_const_unstable(feature = "const_int_overflowing", issue = "53718")]
17181720
#[must_use = "this returns the result of the operation, \
17191721
without modifying the original"]
1720-
pub fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
1722+
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
17211723
if self == Self::min_value() && rhs == -1 {
17221724
(0, true)
17231725
} else {
@@ -3639,9 +3641,10 @@ Basic usage
36393641
```"),
36403642
#[inline]
36413643
#[stable(feature = "wrapping", since = "1.7.0")]
3644+
#[rustc_const_unstable(feature = "const_int_overflowing", issue = "53718")]
36423645
#[must_use = "this returns the result of the operation, \
36433646
without modifying the original"]
3644-
pub fn overflowing_div(self, rhs: Self) -> (Self, bool) {
3647+
pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) {
36453648
(self / rhs, false)
36463649
}
36473650
}
@@ -3699,9 +3702,10 @@ Basic usage
36993702
```"),
37003703
#[inline]
37013704
#[stable(feature = "wrapping", since = "1.7.0")]
3705+
#[rustc_const_unstable(feature = "const_int_overflowing", issue = "53718")]
37023706
#[must_use = "this returns the result of the operation, \
37033707
without modifying the original"]
3704-
pub fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
3708+
pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
37053709
(self % rhs, false)
37063710
}
37073711
}

0 commit comments

Comments
 (0)