Merge pull request #2558 from Mingun/correct-span

Improve error reporting about mismatched signature in `with` and `default` attributes
This commit is contained in:
Oli Scherer
2024-10-21 21:38:09 +02:00
committed by GitHub
27 changed files with 628 additions and 13 deletions
+7 -1
View File
@@ -1220,9 +1220,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>,
}