Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix generated code for deserializing untagged newtype variant #1269

Merged
merged 1 commit into from
May 20, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 2 additions & 4 deletions serde_derive/src/de.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1802,10 +1802,8 @@ fn deserialize_untagged_newtype_variant(
}
Some(path) => {
quote_block! {
let __value: #field_ty = _serde::export::Result::map(
#path(#deserializer),
#this::#variant_ident);
__value
let __value: _serde::export::Result<#field_ty, _> = #path(#deserializer);
_serde::export::Result::map(__value, #this::#variant_ident)
}
}
}
Expand Down
10 changes: 10 additions & 0 deletions test_suite/tests/test_gen.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,6 +643,16 @@ fn test_gen() {
struct ImpliciltyBorrowedOption<'a> {
option: std::option::Option<&'a str>,
}

#[derive(Serialize, Deserialize)]
#[serde(untagged)]
enum UntaggedNewtypeVariantWith {
Newtype(
#[serde(serialize_with = "ser_x")]
#[serde(deserialize_with = "de_x")]
X,
),
}
}

//////////////////////////////////////////////////////////////////////////
Expand Down