Produce error about mismatched types of #[serde(with = "...")] and #[serde(default = "...")] attributes on the attribute itself

This commit is contained in:
Mingun
2023-07-22 19:44:59 +05:00
committed by Mingun
parent 291ec50d98
commit 74b538b8ec
3 changed files with 59 additions and 13 deletions
+7 -1
View File
@@ -1229,9 +1229,15 @@ fn wrap_serialize_with(
})
});
quote!({
// If #serialize_with returns wrong type, error will be reported on here.
// We attach span of the path to this piece so error will be reported
// on the #[serde(with = "...")]
// ^^^^^
quote_spanned!(serialize_with.span()=> {
#[doc(hidden)]
struct __SerializeWith #wrapper_impl_generics #where_clause {
// If #field_tys is empty, `values` does not used
#[allow(dead_code)]
values: (#(&'__a #field_tys, )*),
phantom: _serde::__private::PhantomData<#this_type #ty_generics>,
}