]> git.lizzy.rs Git - rust.git/commitdiff
Workaround deliberate overflowing negation in serialize::json.
authorFelix S. Klock II <pnkfelix@pnkfx.org>
Thu, 16 Apr 2015 14:48:14 +0000 (16:48 +0200)
committerFelix S. Klock II <pnkfelix@pnkfx.org>
Fri, 17 Apr 2015 12:54:55 +0000 (14:54 +0200)
src/libserialize/json.rs

index 8f020d0857d7bcd17f8ef61bffb5330b91e202e8..b4f679a81098901f0f4863eb0af100d09cce1e15 100644 (file)
@@ -1540,7 +1540,7 @@ fn parse_number(&mut self) -> JsonEvent {
             F64Value(res)
         } else {
             if neg {
-                let res = -(res as i64);
+                let res = (res as i64).wrapping_neg();
 
                 // Make sure we didn't underflow.
                 if res > 0 {