From a22ad2581487431e549236df1c3b31b3324567e2 Mon Sep 17 00:00:00 2001 From: Brian Anderson Date: Fri, 24 Apr 2015 14:50:07 -0700 Subject: [PATCH] Fix fallout from wrapping_neg revert --- src/libcore/num/mod.rs | 2 +- src/libserialize/json.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 89e6330f07b0..1b0dd73d1060 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -506,7 +506,7 @@ macro_rules! int_impl { #[inline] pub fn abs(self) -> $T { if self.is_negative() { - self.wrapping_neg() + !self + 1 // wrapping_neg } else { self } diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index f17ce14f9eff..f57b852ea53d 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1538,7 +1538,7 @@ impl> Parser { F64Value(res) } else { if neg { - let res = (res as i64).wrapping_neg(); + let res = !(res as i64) + 1; // wrapping_neg // Make sure we didn't underflow. if res > 0 {