Skip to content

Commit

Permalink
Fix new dead_code warning in tuple struct and tuple variant remote defs
Browse files Browse the repository at this point in the history
  • Loading branch information
dtolnay committed Jan 6, 2024
1 parent 6f1a8c3 commit 6502b31
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions serde_derive/src/pretend.rs
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,14 @@ pub fn pretend_used(cont: &Container, is_packed: bool) -> TokenStream {
fn pretend_fields_used(cont: &Container, is_packed: bool) -> TokenStream {
match &cont.data {
Data::Enum(variants) => pretend_fields_used_enum(cont, variants),
Data::Struct(Style::Struct, fields) => {
Data::Struct(Style::Struct | Style::Tuple | Style::Newtype, fields) => {
if is_packed {
pretend_fields_used_struct_packed(cont, fields)
} else {
pretend_fields_used_struct(cont, fields)
}
}
Data::Struct(_, _) => quote!(),
Data::Struct(Style::Unit, _) => quote!(),
}
}

Expand Down Expand Up @@ -115,13 +115,13 @@ fn pretend_fields_used_enum(cont: &Container, variants: &[Variant]) -> TokenStre
let patterns = variants
.iter()
.filter_map(|variant| match variant.style {
Style::Struct => {
Style::Struct | Style::Tuple | Style::Newtype => {
let variant_ident = &variant.ident;
let members = variant.fields.iter().map(|field| &field.member);
let placeholders = (0usize..).map(|i| format_ident!("__v{}", i));
Some(quote!(#type_ident::#variant_ident { #(#members: #placeholders),* }))
}
_ => None,
Style::Unit => None,
})
.collect::<Vec<_>>();

Expand Down

0 comments on commit 6502b31

Please sign in to comment.