From 6699b0bc404663064189c3a34d7934475741b3e5 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Mon, 25 Jan 2021 13:25:53 -0800 Subject: [PATCH] Add regression test for issue 1969 --- test_suite/tests/test_gen.rs | 15 +++++++++++++++ 1 file changed, 15 insertions(+) diff --git a/test_suite/tests/test_gen.rs b/test_suite/tests/test_gen.rs index 73f7fa50f..002885ead 100644 --- a/test_suite/tests/test_gen.rs +++ b/test_suite/tests/test_gen.rs @@ -7,6 +7,7 @@ #![allow( unknown_lints, mixed_script_confusables, + clippy::ptr_arg, clippy::trivially_copy_pass_by_ref )] @@ -735,6 +736,12 @@ fn test_gen() { #[serde(borrow = "'a")] f: mac!(Cow<'a, str>), } + + #[derive(Serialize)] + struct Struct { + #[serde(serialize_with = "vec_first_element")] + vec: Vec, + } } ////////////////////////////////////////////////////////////////////////// @@ -808,3 +815,11 @@ where pub fn is_zero(n: &u8) -> bool { *n == 0 } + +fn vec_first_element(vec: &Vec, serializer: S) -> StdResult +where + T: Serialize, + S: Serializer, +{ + vec.first().serialize(serializer) +}