about summary refs log tree commit diff
path: root/src/libcore
diff options
context:
space:
mode:
authorDylan MacKenzie <ecstaticmorse@gmail.com>2020-02-03 12:45:51 -0800
committerDylan MacKenzie <ecstaticmorse@gmail.com>2020-02-04 11:04:03 -0800
commitde52a541d5daab8393d4da8a9508fb7b5c1448e0 (patch)
tree820b8e3a92ccd61ba8229926388979968c7f6672 /src/libcore
parent37c141885ac5972e7c858d65babe1753b0ad994c (diff)
downloadrust-de52a541d5daab8393d4da8a9508fb7b5c1448e0.tar.gz
rust-de52a541d5daab8393d4da8a9508fb7b5c1448e0.zip
Make overflowing arithmetic `const`
Co-Authored-By: 9999years <rbt@sent.as>
Diffstat (limited to 'src/libcore')
-rw-r--r--src/libcore/lib.rs1
-rw-r--r--src/libcore/num/mod.rs12
2 files changed, 9 insertions, 4 deletions
diff --git a/src/libcore/lib.rs b/src/libcore/lib.rs
index 78b1524f04f..f8857b9d733 100644
--- a/src/libcore/lib.rs
+++ b/src/libcore/lib.rs
@@ -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)]
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 91df649f121..690a07ce680 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -1646,9 +1646,10 @@ $EndFeature, "
 ```"),
             #[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 @@ $EndFeature, "
 ```"),
             #[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 @@ Basic usage
 ```"),
             #[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 @@ Basic usage
 ```"),
             #[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)
             }
         }