Fix adjacently tagged empty tuple variant or struct variant

This commit is contained in:
David Tolnay 2018-05-06 21:49:37 -07:00
parent 9dc05c36f0
commit 3cd9d071c2
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 12 additions and 1 deletions

View File

@ -645,7 +645,7 @@ fn serialize_adjacently_tagged_variant(
let (_, ty_generics, where_clause) = params.generics.split_for_impl();
let wrapper_generics = if let Style::Unit = variant.style {
let wrapper_generics = if fields_ident.is_empty() {
params.generics.clone()
} else {
bound::with_lifetime_bound(&params.generics, "'__a")

View File

@ -567,6 +567,17 @@ fn test_gen() {
}
assert::<AssocDeriveMulti<i32, NoSerdeImpl>>();
#[derive(Serialize)]
#[serde(tag = "t", content = "c")]
enum EmptyAdjacentlyTagged {
#[allow(dead_code)]
Struct {},
#[allow(dead_code)]
Tuple(),
}
assert_ser::<EmptyAdjacentlyTagged>();
}
//////////////////////////////////////////////////////////////////////////