From 91c2f78b504e60e5c82ff3944d6663785bf47eee Mon Sep 17 00:00:00 2001 From: jumbatm Date: Fri, 27 Dec 2019 20:29:39 +1000 Subject: [PATCH] Clean up const-hack from #58044 --- src/libcore/num/mod.rs | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 2148b6c2b415b..14540394caba1 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) + } } }