Fix deserializer bounds on remote derive
This commit is contained in:
parent
4fdba725fe
commit
1d3e921ba6
@ -23,15 +23,14 @@ pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<Tokens, Str
|
|||||||
|
|
||||||
let ident = &cont.ident;
|
let ident = &cont.ident;
|
||||||
let params = Parameters::new(&cont);
|
let params = Parameters::new(&cont);
|
||||||
|
let (de_impl_generics, _, ty_generics, where_clause) = split_with_de_lifetime(¶ms);
|
||||||
let dummy_const = Ident::new(format!("_IMPL_DESERIALIZE_FOR_{}", ident));
|
let dummy_const = Ident::new(format!("_IMPL_DESERIALIZE_FOR_{}", ident));
|
||||||
let body = Stmts(deserialize_body(&cont, ¶ms));
|
let body = Stmts(deserialize_body(&cont, ¶ms));
|
||||||
|
|
||||||
let impl_block = if let Some(remote) = cont.attrs.remote() {
|
let impl_block = if let Some(remote) = cont.attrs.remote() {
|
||||||
let (impl_generics, ty_generics, where_clause) = cont.generics.split_for_impl();
|
|
||||||
let de_lifetime = params.de_lifetime_def();
|
|
||||||
quote! {
|
quote! {
|
||||||
impl #impl_generics #ident #ty_generics #where_clause {
|
impl #de_impl_generics #ident #ty_generics #where_clause {
|
||||||
fn deserialize<#de_lifetime, __D>(__deserializer: __D) -> _serde::export::Result<#remote #ty_generics, __D::Error>
|
fn deserialize<__D>(__deserializer: __D) -> _serde::export::Result<#remote #ty_generics, __D::Error>
|
||||||
where __D: _serde::Deserializer<'de>
|
where __D: _serde::Deserializer<'de>
|
||||||
{
|
{
|
||||||
#body
|
#body
|
||||||
@ -39,7 +38,6 @@ pub fn expand_derive_deserialize(input: &syn::DeriveInput) -> Result<Tokens, Str
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
let (de_impl_generics, _, ty_generics, where_clause) = split_with_de_lifetime(¶ms);
|
|
||||||
quote! {
|
quote! {
|
||||||
#[automatically_derived]
|
#[automatically_derived]
|
||||||
impl #de_impl_generics _serde::Deserialize<'de> for #ident #ty_generics #where_clause {
|
impl #de_impl_generics _serde::Deserialize<'de> for #ident #ty_generics #where_clause {
|
||||||
|
@ -330,6 +330,34 @@ fn test_gen() {
|
|||||||
struct EmptyArray {
|
struct EmptyArray {
|
||||||
empty: [X; 0],
|
empty: [X; 0],
|
||||||
}
|
}
|
||||||
|
|
||||||
|
enum Or<A, B> {
|
||||||
|
A(A),
|
||||||
|
B(B),
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(untagged, remote = "Or")]
|
||||||
|
enum OrDef<A, B> {
|
||||||
|
#[allow(dead_code)]
|
||||||
|
A(A),
|
||||||
|
#[allow(dead_code)]
|
||||||
|
B(B),
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Str<'a>(&'a str);
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
#[serde(remote = "Str")]
|
||||||
|
struct StrDef<'a>(&'a str);
|
||||||
|
|
||||||
|
#[derive(Serialize, Deserialize)]
|
||||||
|
struct Remote<'a> {
|
||||||
|
#[serde(with = "OrDef")]
|
||||||
|
or: Or<u8, bool>,
|
||||||
|
#[serde(borrow, with = "StrDef")]
|
||||||
|
s: Str<'a>,
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
//////////////////////////////////////////////////////////////////////////
|
//////////////////////////////////////////////////////////////////////////
|
||||||
|
Loading…
x
Reference in New Issue
Block a user