Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 1 addition & 6 deletions serde_derive/src/dummy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,7 @@ pub fn wrap_in_const(serde_path: Option<&syn::Path>, code: TokenStream) -> Token

quote! {
#[doc(hidden)]
#[allow(
clippy::needless_lifetimes,
non_upper_case_globals,
unused_attributes,
unused_qualifications,
)]
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
const _: () = {
#use_serde
#code
Expand Down
10 changes: 6 additions & 4 deletions serde_derive/src/ser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1224,11 +1224,13 @@ fn wrap_serialize_with(
// We attach span of the path to this piece so error will be reported
// on the #[serde(with = "...")]
// ^^^^^
quote_spanned!(serialize_with.span()=> {
let wrapper_serialize = quote_spanned! {serialize_with.span()=>
#serialize_with(#(self.values.#field_access, )* __s)
};

quote!({
#[doc(hidden)]
struct __SerializeWith #wrapper_impl_generics #where_clause {
// If #field_tys is empty, this field is unused
#[allow(dead_code)]
values: (#(&'__a #field_tys, )*),
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
}
Expand All @@ -1238,7 +1240,7 @@ fn wrap_serialize_with(
where
__S: _serde::Serializer,
{
#serialize_with(#(self.values.#field_access, )* __s)
#wrapper_serialize
}
}

Expand Down