Resolve conflict with pr 1115

This commit is contained in:
David Tolnay 2017-12-11 20:59:54 -08:00
parent 0c2e91f28a
commit 0dac13e4db
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 31 additions and 0 deletions

View File

@ -673,7 +673,32 @@ fn deserialize_from_seq(
}
});
let this = &params.this;
let (_, ty_generics, _) = params.generics.split_for_impl();
let let_default = match *cattrs.default() {
attr::Default::Default => {
Some(
quote!(
let __default: #this #ty_generics = _serde::export::Default::default();
),
)
}
attr::Default::Path(ref path) => {
Some(
quote!(
let __default: #this #ty_generics = #path();
),
)
}
attr::Default::None => {
// We don't need the default value, to prevent an unused variable warning
// we'll leave the line empty.
None
}
};
quote_block! {
#let_default
#(#write_values)*
_serde::export::Ok(())
}

View File

@ -86,6 +86,12 @@ struct StructSkipDefault {
#[serde(skip_deserializing)] a: i32,
}
#[derive(PartialEq, Debug, Deserialize)]
#[serde(default)]
struct StructSkipDefaultGeneric<T> {
#[serde(skip_deserializing)] t: T,
}
impl Default for StructSkipDefault {
fn default() -> Self {
StructSkipDefault {