mirror of
https://github.com/serde-rs/serde.git
synced 2025-09-27 13:00:49 +00:00
deserialize_untagged_variant
always called with the same deserializer
, so remove that parameter
This commit is contained in:
parent
ca79f61d0f
commit
3a682c951b
@ -1474,12 +1474,7 @@ fn deserialize_adjacently_tagged_enum(
|
|||||||
.map(|(i, variant)| {
|
.map(|(i, variant)| {
|
||||||
let variant_index = field_i(i);
|
let variant_index = field_i(i);
|
||||||
|
|
||||||
let block = Match(deserialize_untagged_variant(
|
let block = Match(deserialize_untagged_variant(params, variant, cattrs));
|
||||||
params,
|
|
||||||
variant,
|
|
||||||
cattrs,
|
|
||||||
quote!(__deserializer),
|
|
||||||
));
|
|
||||||
|
|
||||||
quote! {
|
quote! {
|
||||||
__Field::#variant_index => #block
|
__Field::#variant_index => #block
|
||||||
@ -1773,14 +1768,7 @@ fn deserialize_untagged_enum(
|
|||||||
let attempts = variants
|
let attempts = variants
|
||||||
.iter()
|
.iter()
|
||||||
.filter(|variant| !variant.attrs.skip_deserializing())
|
.filter(|variant| !variant.attrs.skip_deserializing())
|
||||||
.map(|variant| {
|
.map(|variant| Expr(deserialize_untagged_variant(params, variant, cattrs)));
|
||||||
Expr(deserialize_untagged_variant(
|
|
||||||
params,
|
|
||||||
variant,
|
|
||||||
cattrs,
|
|
||||||
quote!(__deserializer),
|
|
||||||
))
|
|
||||||
});
|
|
||||||
// TODO this message could be better by saving the errors from the failed
|
// TODO this message could be better by saving the errors from the failed
|
||||||
// attempts. The heuristic used by TOML was to count the number of fields
|
// attempts. The heuristic used by TOML was to count the number of fields
|
||||||
// processed before an error, and use the error that happened after the
|
// processed before an error, and use the error that happened after the
|
||||||
@ -1905,12 +1893,11 @@ fn deserialize_untagged_variant(
|
|||||||
params: &Parameters,
|
params: &Parameters,
|
||||||
variant: &Variant,
|
variant: &Variant,
|
||||||
cattrs: &attr::Container,
|
cattrs: &attr::Container,
|
||||||
deserializer: TokenStream,
|
|
||||||
) -> Fragment {
|
) -> Fragment {
|
||||||
if let Some(path) = variant.attrs.deserialize_with() {
|
if let Some(path) = variant.attrs.deserialize_with() {
|
||||||
let unwrap_fn = unwrap_to_variant_closure(params, variant, false);
|
let unwrap_fn = unwrap_to_variant_closure(params, variant, false);
|
||||||
return quote_block! {
|
return quote_block! {
|
||||||
_serde::#private::Result::map(#path(#deserializer), #unwrap_fn)
|
_serde::#private::Result::map(#path(__deserializer), #unwrap_fn)
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1927,7 +1914,7 @@ fn deserialize_untagged_variant(
|
|||||||
});
|
});
|
||||||
quote_expr! {
|
quote_expr! {
|
||||||
match _serde::Deserializer::deserialize_any(
|
match _serde::Deserializer::deserialize_any(
|
||||||
#deserializer,
|
__deserializer,
|
||||||
_serde::#private::de::UntaggedUnitVisitor::new(#type_name, #variant_name)
|
_serde::#private::de::UntaggedUnitVisitor::new(#type_name, #variant_name)
|
||||||
) {
|
) {
|
||||||
_serde::#private::Ok(()) => _serde::#private::Ok(#this_value::#variant_ident #default),
|
_serde::#private::Ok(()) => _serde::#private::Ok(#this_value::#variant_ident #default),
|
||||||
@ -1939,19 +1926,19 @@ fn deserialize_untagged_variant(
|
|||||||
variant_ident,
|
variant_ident,
|
||||||
params,
|
params,
|
||||||
&variant.fields[0],
|
&variant.fields[0],
|
||||||
&deserializer,
|
"e!(__deserializer),
|
||||||
),
|
),
|
||||||
Style::Tuple => deserialize_tuple(
|
Style::Tuple => deserialize_tuple(
|
||||||
params,
|
params,
|
||||||
&variant.fields,
|
&variant.fields,
|
||||||
cattrs,
|
cattrs,
|
||||||
TupleForm::Untagged(variant_ident, deserializer),
|
TupleForm::Untagged(variant_ident, quote!(__deserializer)),
|
||||||
),
|
),
|
||||||
Style::Struct => deserialize_struct(
|
Style::Struct => deserialize_struct(
|
||||||
params,
|
params,
|
||||||
&variant.fields,
|
&variant.fields,
|
||||||
cattrs,
|
cattrs,
|
||||||
StructForm::Untagged(variant_ident, deserializer),
|
StructForm::Untagged(variant_ident, quote!(__deserializer)),
|
||||||
),
|
),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user