about summary refs log tree commit diff
path: root/src/libcore/num
diff options
context:
space:
mode:
authorjumbatm <jumbatm@gmail.com>2019-12-27 20:29:39 +1000
committerjumbatm <jumbatm@gmail.com>2019-12-27 23:21:32 +1000
commit91c2f78b504e60e5c82ff3944d6663785bf47eee (patch)
tree282724755f8c11f17f0d4e0175350dc14e19e2ec /src/libcore/num
parent282635f2db06096f1d7f0a986cf39da4c39da449 (diff)
downloadrust-91c2f78b504e60e5c82ff3944d6663785bf47eee.tar.gz
rust-91c2f78b504e60e5c82ff3944d6663785bf47eee.zip
Clean up const-hack from #58044
Diffstat (limited to 'src/libcore/num')
-rw-r--r--src/libcore/num/mod.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs
index 2148b6c2b41..14540394cab 100644
--- a/src/libcore/num/mod.rs
+++ b/src/libcore/num/mod.rs
@@ -1709,8 +1709,13 @@ assert_eq!(", stringify!($SelfT), "::MIN.overflowing_neg(), (", stringify!($Self
             #[inline]
             #[stable(feature = "wrapping", since = "1.7.0")]
             #[rustc_const_stable(feature = "const_int_methods", since = "1.32.0")]
+            #[allow_internal_unstable(const_if_match)]
             pub const fn overflowing_neg(self) -> (Self, bool) {
-                ((!self).wrapping_add(1), self == Self::min_value())
+                if self == Self::min_value() {
+                    (Self::min_value(), true)
+                } else {
+                    (-self, false)
+                }
             }
         }