Remove a layer of wrapping in deserialize_with untagged newtype variant

This commit is contained in:
David Tolnay 2018-05-05 00:25:27 -07:00
parent 0e1d065402
commit adb1c9540d
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82

View File

@ -1694,9 +1694,9 @@ fn deserialize_untagged_newtype_variant(
deserializer: &Tokens, deserializer: &Tokens,
) -> Fragment { ) -> Fragment {
let this = &params.this; let this = &params.this;
let field_ty = field.ty;
match field.attrs.deserialize_with() { match field.attrs.deserialize_with() {
None => { None => {
let field_ty = &field.ty;
quote_expr! { quote_expr! {
_serde::export::Result::map( _serde::export::Result::map(
<#field_ty as _serde::Deserialize>::deserialize(#deserializer), <#field_ty as _serde::Deserialize>::deserialize(#deserializer),
@ -1704,12 +1704,11 @@ fn deserialize_untagged_newtype_variant(
} }
} }
Some(path) => { Some(path) => {
let (wrapper, wrapper_ty) = wrap_deserialize_field_with(params, field.ty, path);
quote_block! { quote_block! {
#wrapper let __value: #field_ty = _serde::export::Result::map(
_serde::export::Result::map( #path(#deserializer),
<#wrapper_ty as _serde::Deserialize>::deserialize(#deserializer), #this::#variant_ident);
|__wrapper| #this::#variant_ident(__wrapper.value)) __value
} }
} }
} }