]> git.lizzy.rs Git - rust.git/commitdiff
Make overflowing arithmetic `const`
authorDylan MacKenzie <ecstaticmorse@gmail.com>
Mon, 3 Feb 2020 20:45:51 +0000 (12:45 -0800)
committerDylan MacKenzie <ecstaticmorse@gmail.com>
Tue, 4 Feb 2020 19:04:03 +0000 (11:04 -0800)
Co-Authored-By: 9999years <rbt@sent.as>
src/libcore/lib.rs
src/libcore/num/mod.rs

index 78b1524f04f83968af6af0e9f7789b297a790e18..f8857b9d733778755d52d45da93b711d1f06f94c 100644 (file)
@@ -74,6 +74,7 @@
 #![feature(const_if_match)]
 #![feature(const_int_checked)]
 #![feature(const_int_euclidean)]
+#![feature(const_int_overflowing)]
 #![feature(const_panic)]
 #![feature(const_fn_union)]
 #![feature(const_generics)]
index 91df649f121e7a277658c4a231b7a1ee3d9ced98..690a07ce68090c3e0e58757bb8a7686f97a5734e 100644 (file)
@@ -1646,9 +1646,10 @@ pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) {
 ```"),
             #[inline]
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[rustc_const_unstable(feature = "const_int_overflowing", issue = "53718")]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
-            pub fn overflowing_div(self, rhs: Self) -> (Self, bool) {
+            pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) {
                 if self == Self::min_value() && rhs == -1 {
                     (self, true)
                 } else {
@@ -1715,9 +1716,10 @@ pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) {
 ```"),
             #[inline]
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[rustc_const_unstable(feature = "const_int_overflowing", issue = "53718")]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
-            pub fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
+            pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
                 if self == Self::min_value() && rhs == -1 {
                     (0, true)
                 } else {
@@ -3639,9 +3641,10 @@ pub const fn overflowing_mul(self, rhs: Self) -> (Self, bool) {
 ```"),
             #[inline]
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[rustc_const_unstable(feature = "const_int_overflowing", issue = "53718")]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
-            pub fn overflowing_div(self, rhs: Self) -> (Self, bool) {
+            pub const fn overflowing_div(self, rhs: Self) -> (Self, bool) {
                 (self / rhs, false)
             }
         }
@@ -3699,9 +3702,10 @@ pub const fn overflowing_div_euclid(self, rhs: Self) -> (Self, bool) {
 ```"),
             #[inline]
             #[stable(feature = "wrapping", since = "1.7.0")]
+            #[rustc_const_unstable(feature = "const_int_overflowing", issue = "53718")]
             #[must_use = "this returns the result of the operation, \
                           without modifying the original"]
-            pub fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
+            pub const fn overflowing_rem(self, rhs: Self) -> (Self, bool) {
                 (self % rhs, false)
             }
         }