mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-02 07:21:12 +00:00
Merge pull request #2841 from dtolnay/serializewith
Reduce scope of quote_spanned on SerializeWith wrapper
This commit is contained in:
commit
830309fcb5
@ -14,12 +14,7 @@ pub fn wrap_in_const(serde_path: Option<&syn::Path>, code: TokenStream) -> Token
|
|||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
#[doc(hidden)]
|
#[doc(hidden)]
|
||||||
#[allow(
|
#[allow(non_upper_case_globals, unused_attributes, unused_qualifications)]
|
||||||
clippy::needless_lifetimes,
|
|
||||||
non_upper_case_globals,
|
|
||||||
unused_attributes,
|
|
||||||
unused_qualifications,
|
|
||||||
)]
|
|
||||||
const _: () = {
|
const _: () = {
|
||||||
#use_serde
|
#use_serde
|
||||||
#code
|
#code
|
||||||
|
@ -1224,11 +1224,13 @@ fn wrap_serialize_with(
|
|||||||
// We attach span of the path to this piece so error will be reported
|
// We attach span of the path to this piece so error will be reported
|
||||||
// on the #[serde(with = "...")]
|
// 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)]
|
#[doc(hidden)]
|
||||||
struct __SerializeWith #wrapper_impl_generics #where_clause {
|
struct __SerializeWith #wrapper_impl_generics #where_clause {
|
||||||
// If #field_tys is empty, this field is unused
|
|
||||||
#[allow(dead_code)]
|
|
||||||
values: (#(&'__a #field_tys, )*),
|
values: (#(&'__a #field_tys, )*),
|
||||||
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
|
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
|
||||||
}
|
}
|
||||||
@ -1238,7 +1240,7 @@ fn wrap_serialize_with(
|
|||||||
where
|
where
|
||||||
__S: _serde::Serializer,
|
__S: _serde::Serializer,
|
||||||
{
|
{
|
||||||
#serialize_with(#(self.values.#field_access, )* __s)
|
#wrapper_serialize
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user