mirror of
https://github.com/serde-rs/serde.git
synced 2025-09-28 13:30:48 +00:00
TupleForm::Untagged always instantiated with the same deserializer, so remove that parameter
This commit is contained in:
parent
915686d0ec
commit
896d91f0bb
@ -480,9 +480,8 @@ enum TupleForm<'a> {
|
|||||||
Tuple,
|
Tuple,
|
||||||
/// Contains a variant name
|
/// Contains a variant name
|
||||||
ExternallyTagged(&'a syn::Ident),
|
ExternallyTagged(&'a syn::Ident),
|
||||||
/// Contains a variant name and an intermediate deserializer from which actual
|
/// Contains a variant name
|
||||||
/// deserialization will be performed
|
Untagged(&'a syn::Ident),
|
||||||
Untagged(&'a syn::Ident, TokenStream),
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Generates `Deserialize::deserialize` body for a `struct Tuple(...);` including `struct Newtype(T);`
|
/// Generates `Deserialize::deserialize` body for a `struct Tuple(...);` including `struct Newtype(T);`
|
||||||
@ -519,13 +518,13 @@ fn deserialize_tuple(
|
|||||||
|
|
||||||
let type_path = match form {
|
let type_path = match form {
|
||||||
TupleForm::Tuple => construct,
|
TupleForm::Tuple => construct,
|
||||||
TupleForm::ExternallyTagged(variant_ident) | TupleForm::Untagged(variant_ident, _) => {
|
TupleForm::ExternallyTagged(variant_ident) | TupleForm::Untagged(variant_ident) => {
|
||||||
quote!(#construct::#variant_ident)
|
quote!(#construct::#variant_ident)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
let expecting = match form {
|
let expecting = match form {
|
||||||
TupleForm::Tuple => format!("tuple struct {}", params.type_name()),
|
TupleForm::Tuple => format!("tuple struct {}", params.type_name()),
|
||||||
TupleForm::ExternallyTagged(variant_ident) | TupleForm::Untagged(variant_ident, _) => {
|
TupleForm::ExternallyTagged(variant_ident) | TupleForm::Untagged(variant_ident) => {
|
||||||
format!("tuple variant {}::{}", params.type_name(), variant_ident)
|
format!("tuple variant {}::{}", params.type_name(), variant_ident)
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -566,8 +565,8 @@ fn deserialize_tuple(
|
|||||||
TupleForm::ExternallyTagged(_) => quote! {
|
TupleForm::ExternallyTagged(_) => quote! {
|
||||||
_serde::de::VariantAccess::tuple_variant(__variant, #field_count, #visitor_expr)
|
_serde::de::VariantAccess::tuple_variant(__variant, #field_count, #visitor_expr)
|
||||||
},
|
},
|
||||||
TupleForm::Untagged(_, deserializer) => quote! {
|
TupleForm::Untagged(_) => quote! {
|
||||||
_serde::Deserializer::deserialize_tuple(#deserializer, #field_count, #visitor_expr)
|
_serde::Deserializer::deserialize_tuple(__deserializer, #field_count, #visitor_expr)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -1926,7 +1925,7 @@ fn deserialize_untagged_variant(
|
|||||||
params,
|
params,
|
||||||
&variant.fields,
|
&variant.fields,
|
||||||
cattrs,
|
cattrs,
|
||||||
TupleForm::Untagged(variant_ident, quote!(__deserializer)),
|
TupleForm::Untagged(variant_ident),
|
||||||
),
|
),
|
||||||
Style::Struct => deserialize_struct(
|
Style::Struct => deserialize_struct(
|
||||||
params,
|
params,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user