From 697b082e90ea4c8204786d74d7271b0c27a63bd6 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Fri, 5 Mar 2021 19:36:25 -0800 Subject: [PATCH] Touch up PR 1997 --- serde/build.rs | 2 +- serde/src/de/impls.rs | 2 +- test_suite/tests/test_de.rs | 9 --------- test_suite/tests/test_macros.rs | 5 ++++- 4 files changed, 6 insertions(+), 12 deletions(-) diff --git a/serde/build.rs b/serde/build.rs index d9fd9407..afda2911 100644 --- a/serde/build.rs +++ b/serde/build.rs @@ -76,7 +76,7 @@ fn main() { println!("cargo:rustc-cfg=serde_derive"); } - // TryFrom, Atomic types, non-zero signed integers, and `SystemTime::checked_add` + // TryFrom, Atomic types, non-zero signed integers, and SystemTime::checked_add // stabilized in Rust 1.34: // https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#tryfrom-and-tryinto // https://blog.rust-lang.org/2019/04/11/Rust-1.34.0.html#library-stabilizations diff --git a/serde/src/de/impls.rs b/serde/src/de/impls.rs index bd10f7fe..59d90d2c 100644 --- a/serde/src/de/impls.rs +++ b/serde/src/de/impls.rs @@ -2130,7 +2130,7 @@ impl<'de> Deserialize<'de> for SystemTime { #[cfg(systemtime_checked_add)] let ret = UNIX_EPOCH .checked_add(duration) - .ok_or(D::Error::custom("overflow deserializing SystemTime")); + .ok_or_else(|| D::Error::custom("overflow deserializing SystemTime")); #[cfg(not(systemtime_checked_add))] let ret = Ok(UNIX_EPOCH + duration); ret diff --git a/test_suite/tests/test_de.rs b/test_suite/tests/test_de.rs index fb77f8d9..e1a6ea21 100644 --- a/test_suite/tests/test_de.rs +++ b/test_suite/tests/test_de.rs @@ -192,15 +192,6 @@ macro_rules! declare_tests { } macro_rules! declare_error_tests { - ($($name:ident<$target:ty> { $tokens:expr, $expected:expr, })+) => { - $( - #[test] - fn $name() { - assert_de_tokens_error::<$target>($tokens, $expected); - } - )+ - }; - ($( $(#[$cfg:meta])* $name:ident<$target:ty> { $tokens:expr, $expected:expr, } diff --git a/test_suite/tests/test_macros.rs b/test_suite/tests/test_macros.rs index 4d67a647..a6f13027 100644 --- a/test_suite/tests/test_macros.rs +++ b/test_suite/tests/test_macros.rs @@ -1903,7 +1903,10 @@ fn test_internally_tagged_newtype_variant_containing_unit_struct() { assert_de_tokens( &Message::Info(Info), &[ - Token::Struct { name: "Message", len: 1 }, + Token::Struct { + name: "Message", + len: 1, + }, Token::Str("topic"), Token::Str("Info"), Token::StructEnd,