diff options
| author | jumbatm <jumbatm@gmail.com> | 2019-12-27 20:29:39 +1000 |
|---|---|---|
| committer | jumbatm <jumbatm@gmail.com> | 2019-12-27 23:21:32 +1000 |
| commit | 91c2f78b504e60e5c82ff3944d6663785bf47eee (patch) | |
| tree | 282724755f8c11f17f0d4e0175350dc14e19e2ec /src | |
| parent | 282635f2db06096f1d7f0a986cf39da4c39da449 (diff) | |
| download | rust-91c2f78b504e60e5c82ff3944d6663785bf47eee.tar.gz rust-91c2f78b504e60e5c82ff3944d6663785bf47eee.zip | |
Clean up const-hack from #58044
Diffstat (limited to 'src')
| -rw-r--r-- | src/libcore/num/mod.rs | 7 |
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) + } } } |
