mirror of
https://github.com/serde-rs/serde.git
synced 2025-10-01 15:01:49 +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! {
|
||||
#[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
|
||||
|
@ -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>,
|
||||
}
|
||||
@ -1238,7 +1240,7 @@ fn wrap_serialize_with(
|
||||
where
|
||||
__S: _serde::Serializer,
|
||||
{
|
||||
#serialize_with(#(self.values.#field_access, )* __s)
|
||||
#wrapper_serialize
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user