Skip to content

Commit 830309f

Browse files
authored
Merge pull request #2841 from dtolnay/serializewith
Reduce scope of quote_spanned on SerializeWith wrapper
2 parents 00460b8 + ab4f3f3 commit 830309f

File tree

2 files changed

+7
-10
lines changed

2 files changed

+7
-10
lines changed

serde_derive/src/dummy.rs

+1-6
Original file line numberDiff line numberDiff line change
@@ -14,12 +14,7 @@ pub fn wrap_in_const(serde_path: Option<&syn::Path>, code: TokenStream) -> Token
1414

1515
quote! {
1616
#[doc(hidden)]
17-
#[allow(
18-
clippy::needless_lifetimes,
19-
non_upper_case_globals,
20-
unused_attributes,
21-
unused_qualifications,
22-
)]
17+
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
2318
const _: () = {
2419
#use_serde
2520
#code

serde_derive/src/ser.rs

+6-4
Original file line numberDiff line numberDiff line change
@@ -1224,11 +1224,13 @@ fn wrap_serialize_with(
12241224
// We attach span of the path to this piece so error will be reported
12251225
// on the #[serde(with = "...")]
12261226
// ^^^^^
1227-
quote_spanned!(serialize_with.span()=> {
1227+
let wrapper_serialize = quote_spanned! {serialize_with.span()=>
1228+
#serialize_with(#(self.values.#field_access, )* __s)
1229+
};
1230+
1231+
quote!({
12281232
#[doc(hidden)]
12291233
struct __SerializeWith #wrapper_impl_generics #where_clause {
1230-
// If #field_tys is empty, this field is unused
1231-
#[allow(dead_code)]
12321234
values: (#(&'__a #field_tys, )*),
12331235
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
12341236
}
@@ -1238,7 +1240,7 @@ fn wrap_serialize_with(
12381240
where
12391241
__S: _serde::Serializer,
12401242
{
1241-
#serialize_with(#(self.values.#field_access, )* __s)
1243+
#wrapper_serialize
12421244
}
12431245
}
12441246

0 commit comments

Comments
 (0)