Skip to content

Commit 0baba28

Browse files
committed
Resolve legacy_numeric_constants clippy lints
warning: usage of a legacy numeric method --> src/de.rs:484:73 | 484 | ... if overflow!(significand * 10 + digit, u64::max_value()) { | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default help: use the associated constant instead | 484 | if overflow!(significand * 10 + digit, u64::MAX) { | ~~~ warning: usage of a legacy numeric method --> src/de.rs:536:57 | 536 | if overflow!(significand * 10 + digit, u64::max_value()) { | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 536 | if overflow!(significand * 10 + digit, u64::MAX) { | ~~~ warning: usage of a legacy numeric method --> src/de.rs:600:49 | 600 | if overflow!(exp * 10 + digit, i32::max_value()) { | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 600 | if overflow!(exp * 10 + digit, i32::MAX) { | ~~~ warning: usage of a legacy numeric method --> src/number.rs:100:39 | 100 | N::PosInt(v) => v <= i64::max_value() as u64, | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 100 | N::PosInt(v) => v <= i64::MAX as u64, | ~~~ warning: usage of a legacy numeric method --> src/number.rs:192:30 | 192 | if n <= i64::max_value() as u64 { | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 192 | if n <= i64::MAX as u64 { | ~~~ warning: usage of a legacy numeric method --> tests/../src/lexical/exponent.rs:11:21 | 11 | if value > i32::max_value() as usize { | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default help: use the associated constant instead | 11 | if value > i32::MAX as usize { | ~~~ warning: usage of a legacy numeric method --> tests/../src/lexical/exponent.rs:12:14 | 12 | i32::max_value() | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 12 | i32::MAX | ~~~ warning: usage of a legacy numeric method --> tests/../src/lexical/rounding.rs:28:14 | 28 | u64::max_value() | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 28 | u64::MAX | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:21:34 | 21 | scientific_exponent(i32::min_value(), 0, 0), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 21 | scientific_exponent(i32::MIN, 0, 0), | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:22:14 | 22 | i32::min_value() | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 22 | i32::MIN | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:25:34 | 25 | scientific_exponent(i32::min_value(), 0, 5), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 25 | scientific_exponent(i32::MIN, 0, 5), | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:26:14 | 26 | i32::min_value() | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 26 | i32::MIN | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:31:34 | 31 | scientific_exponent(i32::max_value(), 0, 0), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 31 | scientific_exponent(i32::MAX, 0, 0), | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:32:14 | 32 | i32::max_value() - 1 | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 32 | i32::MAX - 1 | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:35:34 | 35 | scientific_exponent(i32::max_value(), 5, 0), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 35 | scientific_exponent(i32::MAX, 5, 0), | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:36:14 | 36 | i32::max_value() | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 36 | i32::MAX | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:45:32 | 45 | mantissa_exponent(i32::max_value(), 5, 0), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 45 | mantissa_exponent(i32::MAX, 5, 0), | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:46:14 | 46 | i32::max_value() - 5 | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 46 | i32::MAX - 5 | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:48:39 | 48 | assert_eq!(mantissa_exponent(i32::max_value(), 0, 5), i32::max_value()); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 48 | assert_eq!(mantissa_exponent(i32::MAX, 0, 5), i32::max_value()); | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:48:64 | 48 | assert_eq!(mantissa_exponent(i32::max_value(), 0, 5), i32::max_value()); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 48 | assert_eq!(mantissa_exponent(i32::max_value(), 0, 5), i32::MAX); | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:49:39 | 49 | assert_eq!(mantissa_exponent(i32::min_value(), 5, 0), i32::min_value()); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 49 | assert_eq!(mantissa_exponent(i32::MIN, 5, 0), i32::min_value()); | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:49:64 | 49 | assert_eq!(mantissa_exponent(i32::min_value(), 5, 0), i32::min_value()); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 49 | assert_eq!(mantissa_exponent(i32::min_value(), 5, 0), i32::MIN); | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:51:32 | 51 | mantissa_exponent(i32::min_value(), 0, 5), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 51 | mantissa_exponent(i32::MIN, 0, 5), | ~~~ warning: usage of a legacy numeric method --> tests/lexical/exponent.rs:52:14 | 52 | i32::min_value() + 5 | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 52 | i32::MIN + 5 | ~~~ warning: importing legacy numeric constants --> tests/test.rs:47:11 | 47 | use std::{i16, i32, i64, i8}; | ^^^ | = help: remove this import = note: then `i16::<CONST>` will resolve to the respective associated constant = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `#[warn(clippy::legacy_numeric_constants)]` on by default warning: importing legacy numeric constants --> tests/test.rs:47:16 | 47 | use std::{i16, i32, i64, i8}; | ^^^ | = help: remove this import = note: then `i32::<CONST>` will resolve to the respective associated constant = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants warning: importing legacy numeric constants --> tests/test.rs:47:21 | 47 | use std::{i16, i32, i64, i8}; | ^^^ | = help: remove this import = note: then `i64::<CONST>` will resolve to the respective associated constant = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants warning: importing legacy numeric constants --> tests/test.rs:47:26 | 47 | use std::{i16, i32, i64, i8}; | ^^ | = help: remove this import = note: then `i8::<CONST>` will resolve to the respective associated constant = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants warning: importing legacy numeric constants --> tests/test.rs:48:11 | 48 | use std::{u16, u32, u64, u8}; | ^^^ | = help: remove this import = note: then `u16::<CONST>` will resolve to the respective associated constant = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants warning: importing legacy numeric constants --> tests/test.rs:48:16 | 48 | use std::{u16, u32, u64, u8}; | ^^^ | = help: remove this import = note: then `u32::<CONST>` will resolve to the respective associated constant = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants warning: importing legacy numeric constants --> tests/test.rs:48:21 | 48 | use std::{u16, u32, u64, u8}; | ^^^ | = help: remove this import = note: then `u64::<CONST>` will resolve to the respective associated constant = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants warning: importing legacy numeric constants --> tests/test.rs:48:26 | 48 | use std::{u16, u32, u64, u8}; | ^^ | = help: remove this import = note: then `u8::<CONST>` will resolve to the respective associated constant = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants warning: usage of a legacy numeric constant --> tests/test.rs:161:22 | 161 | let v = to_value(::std::f64::NAN.copysign(1.0)).unwrap(); | ^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 161 | let v = to_value(f64::NAN.copysign(1.0)).unwrap(); | ~~~~~~~~ warning: usage of a legacy numeric constant --> tests/test.rs:164:22 | 164 | let v = to_value(::std::f64::NAN.copysign(-1.0)).unwrap(); | ^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 164 | let v = to_value(f64::NAN.copysign(-1.0)).unwrap(); | ~~~~~~~~ warning: usage of a legacy numeric constant --> tests/test.rs:167:22 | 167 | let v = to_value(::std::f64::INFINITY).unwrap(); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 167 | let v = to_value(f64::INFINITY).unwrap(); | ~~~~~~~~~~~~~ warning: usage of a legacy numeric constant --> tests/test.rs:170:23 | 170 | let v = to_value(-::std::f64::INFINITY).unwrap(); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 170 | let v = to_value(-f64::INFINITY).unwrap(); | ~~~~~~~~~~~~~ warning: usage of a legacy numeric constant --> tests/test.rs:173:22 | 173 | let v = to_value(::std::f32::NAN.copysign(1.0)).unwrap(); | ^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 173 | let v = to_value(f32::NAN.copysign(1.0)).unwrap(); | ~~~~~~~~ warning: usage of a legacy numeric constant --> tests/test.rs:176:22 | 176 | let v = to_value(::std::f32::NAN.copysign(-1.0)).unwrap(); | ^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 176 | let v = to_value(f32::NAN.copysign(-1.0)).unwrap(); | ~~~~~~~~ warning: usage of a legacy numeric constant --> tests/test.rs:179:22 | 179 | let v = to_value(::std::f32::INFINITY).unwrap(); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 179 | let v = to_value(f32::INFINITY).unwrap(); | ~~~~~~~~~~~~~ warning: usage of a legacy numeric constant --> tests/test.rs:182:23 | 182 | let v = to_value(-::std::f32::INFINITY).unwrap(); | ^^^^^^^^^^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 182 | let v = to_value(-f32::INFINITY).unwrap(); | ~~~~~~~~~~~~~ warning: usage of a legacy numeric method --> tests/test.rs:2243:26 | 2243 | let signed = &[i128::min_value(), -1, 0, 1, i128::max_value()]; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 2243 | let signed = &[i128::MIN, -1, 0, 1, i128::max_value()]; | ~~~ warning: usage of a legacy numeric method --> tests/test.rs:2243:55 | 2243 | let signed = &[i128::min_value(), -1, 0, 1, i128::max_value()]; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 2243 | let signed = &[i128::min_value(), -1, 0, 1, i128::MAX]; | ~~~ warning: usage of a legacy numeric method --> tests/test.rs:2244:34 | 2244 | let unsigned = &[0, 1, u128::max_value()]; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 2244 | let unsigned = &[0, 1, u128::MAX]; | ~~~ warning: usage of a legacy numeric method --> tests/test.rs:2280:36 | 2280 | let signed = &[i128::from(i64::min_value()), i128::from(u64::max_value())]; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 2280 | let signed = &[i128::from(i64::MIN), i128::from(u64::max_value())]; | ~~~ warning: usage of a legacy numeric method --> tests/test.rs:2280:66 | 2280 | let signed = &[i128::from(i64::min_value()), i128::from(u64::max_value())]; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 2280 | let signed = &[i128::from(i64::min_value()), i128::from(u64::MAX)]; | ~~~ warning: usage of a legacy numeric method --> tests/test.rs:2281:41 | 2281 | let unsigned = &[0, u128::from(u64::max_value())]; | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 2281 | let unsigned = &[0, u128::from(u64::MAX)]; | ~~~ warning: usage of a legacy numeric method --> tests/test.rs:2294:44 | 2294 | let err = to_value(u128::from(u64::max_value()) + 1).unwrap_err(); | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants help: use the associated constant instead | 2294 | let err = to_value(u128::from(u64::MAX) + 1).unwrap_err(); | ~~~
1 parent b1ebf38 commit 0baba28

File tree

6 files changed

+32
-52
lines changed

6 files changed

+32
-52
lines changed

src/de.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ impl<'de, R: Read<'de>> Deserializer<R> {
481481
// try to keep the number as a `u64` until we grow
482482
// too large. At that point, switch to parsing the
483483
// value as a `f64`.
484-
if overflow!(significand * 10 + digit, u64::max_value()) {
484+
if overflow!(significand * 10 + digit, u64::MAX) {
485485
return Ok(ParserNumber::F64(tri!(
486486
self.parse_long_integer(positive, significand),
487487
)));
@@ -533,7 +533,7 @@ impl<'de, R: Read<'de>> Deserializer<R> {
533533
while let c @ b'0'..=b'9' = tri!(self.peek_or_null()) {
534534
let digit = (c - b'0') as u64;
535535

536-
if overflow!(significand * 10 + digit, u64::max_value()) {
536+
if overflow!(significand * 10 + digit, u64::MAX) {
537537
let exponent = exponent_before_decimal_point + exponent_after_decimal_point;
538538
return self.parse_decimal_overflow(positive, significand, exponent);
539539
}
@@ -597,7 +597,7 @@ impl<'de, R: Read<'de>> Deserializer<R> {
597597
self.eat_char();
598598
let digit = (c - b'0') as i32;
599599

600-
if overflow!(exp * 10 + digit, i32::max_value()) {
600+
if overflow!(exp * 10 + digit, i32::MAX) {
601601
let zero_significand = significand == 0;
602602
return self.parse_exponent_overflow(positive, zero_significand, positive_exp);
603603
}
@@ -789,7 +789,7 @@ impl<'de, R: Read<'de>> Deserializer<R> {
789789
self.eat_char();
790790
let digit = (c - b'0') as i32;
791791

792-
if overflow!(exp * 10 + digit, i32::max_value()) {
792+
if overflow!(exp * 10 + digit, i32::MAX) {
793793
let zero_significand = self.scratch.iter().all(|&digit| digit == b'0');
794794
return self.parse_exponent_overflow(positive, zero_significand, positive_exp);
795795
}

src/lexical/exponent.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,8 +8,8 @@
88
/// the mantissa we do not overflow for comically-long exponents.
99
#[inline]
1010
fn into_i32(value: usize) -> i32 {
11-
if value > i32::max_value() as usize {
12-
i32::max_value()
11+
if value > i32::MAX as usize {
12+
i32::MAX
1313
} else {
1414
value as i32
1515
}

src/lexical/rounding.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ pub(crate) fn lower_n_mask(n: u64) -> u64 {
2525
debug_assert!(n <= bits, "lower_n_mask() overflow in shl.");
2626

2727
if n == bits {
28-
u64::max_value()
28+
u64::MAX
2929
} else {
3030
(1 << n) - 1
3131
}

src/number.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ impl Number {
8282
/// ```
8383
/// # use serde_json::json;
8484
/// #
85-
/// let big = i64::max_value() as u64 + 10;
85+
/// let big = i64::MAX as u64 + 10;
8686
/// let v = json!({ "a": 64, "b": big, "c": 256.0 });
8787
///
8888
/// assert!(v["a"].is_i64());
@@ -97,7 +97,7 @@ impl Number {
9797
pub fn is_i64(&self) -> bool {
9898
#[cfg(not(feature = "arbitrary_precision"))]
9999
match self.n {
100-
N::PosInt(v) => v <= i64::max_value() as u64,
100+
N::PosInt(v) => v <= i64::MAX as u64,
101101
N::NegInt(_) => true,
102102
N::Float(_) => false,
103103
}
@@ -177,7 +177,7 @@ impl Number {
177177
/// ```
178178
/// # use serde_json::json;
179179
/// #
180-
/// let big = i64::max_value() as u64 + 10;
180+
/// let big = i64::MAX as u64 + 10;
181181
/// let v = json!({ "a": 64, "b": big, "c": 256.0 });
182182
///
183183
/// assert_eq!(v["a"].as_i64(), Some(64));
@@ -189,7 +189,7 @@ impl Number {
189189
#[cfg(not(feature = "arbitrary_precision"))]
190190
match self.n {
191191
N::PosInt(n) => {
192-
if n <= i64::max_value() as u64 {
192+
if n <= i64::MAX as u64 {
193193
Some(n as i64)
194194
} else {
195195
None

tests/lexical/exponent.rs

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -17,38 +17,20 @@ fn scientific_exponent_test() {
1717
assert_eq!(scientific_exponent(-10, 2, 20), -9);
1818

1919
// Underflow
20-
assert_eq!(
21-
scientific_exponent(i32::min_value(), 0, 0),
22-
i32::min_value()
23-
);
24-
assert_eq!(
25-
scientific_exponent(i32::min_value(), 0, 5),
26-
i32::min_value()
27-
);
20+
assert_eq!(scientific_exponent(i32::MIN, 0, 0), i32::MIN);
21+
assert_eq!(scientific_exponent(i32::MIN, 0, 5), i32::MIN);
2822

2923
// Overflow
30-
assert_eq!(
31-
scientific_exponent(i32::max_value(), 0, 0),
32-
i32::max_value() - 1
33-
);
34-
assert_eq!(
35-
scientific_exponent(i32::max_value(), 5, 0),
36-
i32::max_value()
37-
);
24+
assert_eq!(scientific_exponent(i32::MAX, 0, 0), i32::MAX - 1);
25+
assert_eq!(scientific_exponent(i32::MAX, 5, 0), i32::MAX);
3826
}
3927

4028
#[test]
4129
fn mantissa_exponent_test() {
4230
assert_eq!(mantissa_exponent(10, 5, 0), 5);
4331
assert_eq!(mantissa_exponent(0, 5, 0), -5);
44-
assert_eq!(
45-
mantissa_exponent(i32::max_value(), 5, 0),
46-
i32::max_value() - 5
47-
);
48-
assert_eq!(mantissa_exponent(i32::max_value(), 0, 5), i32::max_value());
49-
assert_eq!(mantissa_exponent(i32::min_value(), 5, 0), i32::min_value());
50-
assert_eq!(
51-
mantissa_exponent(i32::min_value(), 0, 5),
52-
i32::min_value() + 5
53-
);
32+
assert_eq!(mantissa_exponent(i32::MAX, 5, 0), i32::MAX - 5);
33+
assert_eq!(mantissa_exponent(i32::MAX, 0, 5), i32::MAX);
34+
assert_eq!(mantissa_exponent(i32::MIN, 5, 0), i32::MIN);
35+
assert_eq!(mantissa_exponent(i32::MIN, 0, 5), i32::MIN + 5);
5436
}

tests/test.rs

Lines changed: 13 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -44,8 +44,6 @@ use std::marker::PhantomData;
4444
use std::mem;
4545
use std::str::FromStr;
4646
use std::{f32, f64};
47-
use std::{i16, i32, i64, i8};
48-
use std::{u16, u32, u64, u8};
4947

5048
macro_rules! treemap {
5149
() => {
@@ -158,28 +156,28 @@ fn test_write_f64() {
158156

159157
#[test]
160158
fn test_encode_nonfinite_float_yields_null() {
161-
let v = to_value(::std::f64::NAN.copysign(1.0)).unwrap();
159+
let v = to_value(f64::NAN.copysign(1.0)).unwrap();
162160
assert!(v.is_null());
163161

164-
let v = to_value(::std::f64::NAN.copysign(-1.0)).unwrap();
162+
let v = to_value(f64::NAN.copysign(-1.0)).unwrap();
165163
assert!(v.is_null());
166164

167-
let v = to_value(::std::f64::INFINITY).unwrap();
165+
let v = to_value(f64::INFINITY).unwrap();
168166
assert!(v.is_null());
169167

170-
let v = to_value(-::std::f64::INFINITY).unwrap();
168+
let v = to_value(-f64::INFINITY).unwrap();
171169
assert!(v.is_null());
172170

173-
let v = to_value(::std::f32::NAN.copysign(1.0)).unwrap();
171+
let v = to_value(f32::NAN.copysign(1.0)).unwrap();
174172
assert!(v.is_null());
175173

176-
let v = to_value(::std::f32::NAN.copysign(-1.0)).unwrap();
174+
let v = to_value(f32::NAN.copysign(-1.0)).unwrap();
177175
assert!(v.is_null());
178176

179-
let v = to_value(::std::f32::INFINITY).unwrap();
177+
let v = to_value(f32::INFINITY).unwrap();
180178
assert!(v.is_null());
181179

182-
let v = to_value(-::std::f32::INFINITY).unwrap();
180+
let v = to_value(-f32::INFINITY).unwrap();
183181
assert!(v.is_null());
184182
}
185183

@@ -2240,8 +2238,8 @@ fn null_invalid_type() {
22402238

22412239
#[test]
22422240
fn test_integer128() {
2243-
let signed = &[i128::min_value(), -1, 0, 1, i128::max_value()];
2244-
let unsigned = &[0, 1, u128::max_value()];
2241+
let signed = &[i128::MIN, -1, 0, 1, i128::MAX];
2242+
let unsigned = &[0, 1, u128::MAX];
22452243

22462244
for integer128 in signed {
22472245
let expected = integer128.to_string();
@@ -2277,8 +2275,8 @@ fn test_integer128() {
22772275

22782276
#[test]
22792277
fn test_integer128_to_value() {
2280-
let signed = &[i128::from(i64::min_value()), i128::from(u64::max_value())];
2281-
let unsigned = &[0, u128::from(u64::max_value())];
2278+
let signed = &[i128::from(i64::MIN), i128::from(u64::MAX)];
2279+
let unsigned = &[0, u128::from(u64::MAX)];
22822280

22832281
for integer128 in signed {
22842282
let expected = integer128.to_string();
@@ -2291,7 +2289,7 @@ fn test_integer128_to_value() {
22912289
}
22922290

22932291
if !cfg!(feature = "arbitrary_precision") {
2294-
let err = to_value(u128::from(u64::max_value()) + 1).unwrap_err();
2292+
let err = to_value(u128::from(u64::MAX) + 1).unwrap_err();
22952293
assert_eq!(err.to_string(), "number out of range");
22962294
}
22972295
}

0 commit comments

Comments
 (0)