Skip to content

Commit 5b24f88

Browse files
committed
Resolve legacy_numeric_constants clippy lints
warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:292:51 | 292 | assert!(fields.len() as u64 <= u64::from(u32::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 | 292 | assert!(fields.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> serde_derive/src/ser.rs:400:53 | 400 | assert!(variants.len() as u64 <= u64::from(u32::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 | 400 | assert!(variants.len() as u64 <= u64::from(u32::MAX)); | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1462:29 | 1462 | Token::U64(u64::max_value()), | ^^^^^^^^^^^ | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#legacy_numeric_constants = note: `-W clippy::legacy-numeric-constants` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::legacy_numeric_constants)]` help: use the associated constant instead | 1462 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1479:29 | 1479 | Token::U64(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 | 1479 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1493:29 | 1493 | Token::U64(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 | 1493 | Token::U64(u64::MAX), | ~~~ warning: usage of a legacy numeric method --> test_suite/tests/test_de_error.rs:1510:29 | 1510 | Token::U64(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 | 1510 | Token::U64(u64::MAX), | ~~~
1 parent 74d0670 commit 5b24f88

File tree

2 files changed

+7
-7
lines changed

2 files changed

+7
-7
lines changed

serde_derive/src/ser.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -289,7 +289,7 @@ fn serialize_tuple_struct(
289289
}
290290

291291
fn serialize_struct(params: &Parameters, fields: &[Field], cattrs: &attr::Container) -> Fragment {
292-
assert!(fields.len() as u64 <= u64::from(u32::max_value()));
292+
assert!(fields.len() as u64 <= u64::from(u32::MAX));
293293

294294
if cattrs.has_flatten() {
295295
serialize_struct_as_map(params, fields, cattrs)
@@ -397,7 +397,7 @@ fn serialize_struct_as_map(
397397
}
398398

399399
fn serialize_enum(params: &Parameters, variants: &[Variant], cattrs: &attr::Container) -> Fragment {
400-
assert!(variants.len() as u64 <= u64::from(u32::max_value()));
400+
assert!(variants.len() as u64 <= u64::from(u32::MAX));
401401

402402
let self_var = &params.self_var;
403403

test_suite/tests/test_de_error.rs

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,7 @@ fn test_duration_overflow_seq() {
14591459
assert_de_tokens_error::<Duration>(
14601460
&[
14611461
Token::Seq { len: Some(2) },
1462-
Token::U64(u64::max_value()),
1462+
Token::U64(u64::MAX),
14631463
Token::U32(1_000_000_000),
14641464
Token::SeqEnd,
14651465
],
@@ -1476,7 +1476,7 @@ fn test_duration_overflow_struct() {
14761476
len: 2,
14771477
},
14781478
Token::Str("secs"),
1479-
Token::U64(u64::max_value()),
1479+
Token::U64(u64::MAX),
14801480
Token::Str("nanos"),
14811481
Token::U32(1_000_000_000),
14821482
Token::StructEnd,
@@ -1490,7 +1490,7 @@ fn test_systemtime_overflow_seq() {
14901490
assert_de_tokens_error::<SystemTime>(
14911491
&[
14921492
Token::Seq { len: Some(2) },
1493-
Token::U64(u64::max_value()),
1493+
Token::U64(u64::MAX),
14941494
Token::U32(1_000_000_000),
14951495
Token::SeqEnd,
14961496
],
@@ -1507,7 +1507,7 @@ fn test_systemtime_overflow_struct() {
15071507
len: 2,
15081508
},
15091509
Token::Str("secs_since_epoch"),
1510-
Token::U64(u64::max_value()),
1510+
Token::U64(u64::MAX),
15111511
Token::Str("nanos_since_epoch"),
15121512
Token::U32(1_000_000_000),
15131513
Token::StructEnd,
@@ -1522,7 +1522,7 @@ fn test_systemtime_overflow() {
15221522
assert_de_tokens_error::<SystemTime>(
15231523
&[
15241524
Token::Seq { len: Some(2) },
1525-
Token::U64(u64::max_value()),
1525+
Token::U64(u64::MAX),
15261526
Token::U32(0),
15271527
Token::SeqEnd,
15281528
],

0 commit comments

Comments
 (0)