diff --git a/serde_with/src/serde_conv.rs b/serde_with/src/serde_conv.rs index 39b3f63a..e93ef79a 100644 --- a/serde_with/src/serde_conv.rs +++ b/serde_with/src/serde_conv.rs @@ -110,6 +110,10 @@ macro_rules! serde_conv { #[allow(non_camel_case_types)] $vis struct $m; + // Prevent clippy lints triggering because of the template here + // https://github.com/jonasbb/serde_with/pull/320 + // https://github.com/jonasbb/serde_with/pull/729 + #[allow(clippy::all)] const _:() = { impl $m { $vis fn serialize(x: &$t, serializer: S) -> $crate::__private__::Result diff --git a/serde_with_test/tests/serde_conv.rs b/serde_with_test/tests/serde_conv.rs index f5a956f9..0dab3ac0 100644 --- a/serde_with_test/tests/serde_conv.rs +++ b/serde_with_test/tests/serde_conv.rs @@ -34,3 +34,16 @@ fn string_to_u32( #[derive(::s::Serialize, ::s::Deserialize)] #[serde(crate = "::s")] struct S2(#[serde(with = "number")] u32); + +// Test for clippy warning clippy::ptr_arg +// warning: writing `&String` instead of `&str` involves a new object where a slice will do +// https://github.com/jonasbb/serde_with/pull/320 +// https://github.com/jonasbb/serde_with/pull/729 +serde_conv!( + pub StringAsHtml, + ::std::string::String, + |string: &str| ::std::borrow::ToOwned::to_owned(string), + |string: ::std::string::String| -> ::std::result::Result<_, ::std::convert::Infallible> { +::std::result::Result::Ok(string) + } +);