diff options
| author | bors <bors@rust-lang.org> | 2015-04-17 22:45:10 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2015-04-17 22:45:10 +0000 |
| commit | b08d6cf529a83caec2f408cd8b1287e493ec57ca (patch) | |
| tree | 6ef971f443e9797d767a2b05f837f9026ba68117 /src/libserialize/json.rs | |
| parent | f305579e490a9fa046b1b7a14e62daf643e41865 (diff) | |
| parent | b8ec7e88fc6c5a81194fd09dad042dc291a1cbb5 (diff) | |
Auto merge of #24500 - pnkfelix:oflo-checked-neg, r=nikomatsakis
Add conditional overflow-checking to signed negate operator. I argue this can land independently of #24420 , because one can write the implementation of `wrapped_neg()` inline if necessary (as illustrated in two cases on this PR). This needs to go into beta channel.
Diffstat (limited to 'src/libserialize/json.rs')
| -rw-r--r-- | src/libserialize/json.rs | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/src/libserialize/json.rs b/src/libserialize/json.rs index 8f020d0857d..b4f679a8109 100644 --- a/src/libserialize/json.rs +++ b/src/libserialize/json.rs @@ -1540,7 +1540,7 @@ impl<T: Iterator<Item=char>> Parser<T> { 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 { |
