Merge pull request #2671 from dtolnay/deadremote

Fix new dead_code warning in tuple struct and tuple variant remote defs
This commit is contained in:
David Tolnay 2024-01-05 18:30:01 -08:00 committed by GitHub
commit 196f311ae2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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!(),
}
}
@ -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<_>>();