From cd154b66a11fdb754abfca413d535185f3bf6a21 Mon Sep 17 00:00:00 2001 From: Colin Snover Date: Sun, 13 Oct 2024 14:05:18 -0500 Subject: [PATCH] Fix new nightly clippy lints (cherry picked from commit 22d9a4d0c3c38a9ad5adc91e9c184fd14542d0ff) --- binrw_derive/src/binrw/combiner.rs | 2 +- binrw_derive/src/binrw/mod.rs | 8 ++++---- binrw_derive/src/named_args/codegen.rs | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/binrw_derive/src/binrw/combiner.rs b/binrw_derive/src/binrw/combiner.rs index bdfe1f6a..db580a00 100644 --- a/binrw_derive/src/binrw/combiner.rs +++ b/binrw_derive/src/binrw/combiner.rs @@ -36,7 +36,7 @@ pub(crate) fn derive(mut derive_input: DeriveInput) -> proc_macro2::TokenStream // Since temporary fields must be synchronised between binread and binwrite, // the same cleaning mechanism can be used as-if there was only one input - super::clean_attr(&mut derive_input, &binread_input.ok()); + super::clean_attr(&mut derive_input, binread_input.ok().as_ref()); quote!( #derive_input diff --git a/binrw_derive/src/binrw/mod.rs b/binrw_derive/src/binrw/mod.rs index d9b71f7a..4002a5cd 100644 --- a/binrw_derive/src/binrw/mod.rs +++ b/binrw_derive/src/binrw/mod.rs @@ -21,7 +21,7 @@ pub(super) struct Options { } #[cfg_attr(coverage_nightly, coverage(off))] -fn clean_attr(derive_input: &mut DeriveInput, binrw_input: &Option) { +fn clean_attr(derive_input: &mut DeriveInput, binrw_input: Option<&Input>) { clean_struct_attrs(&mut derive_input.attrs); match &mut derive_input.data { @@ -43,7 +43,7 @@ fn clean_attr(derive_input: &mut DeriveInput, binrw_input: &Option) { } #[cfg_attr(coverage_nightly, coverage(off))] -fn clean_field_attrs(input: &Option, variant_index: usize, fields: &mut syn::Fields) { +fn clean_field_attrs(input: Option<&Input>, variant_index: usize, fields: &mut syn::Fields) { if let Some(input) = input { let fields = match fields { syn::Fields::Named(fields) => &mut fields.named, @@ -128,12 +128,12 @@ pub(super) fn derive_from_input( match &mut derive_input.data { syn::Data::Struct(st) => { - clean_field_attrs(&binrw_input, 0, &mut st.fields); + clean_field_attrs(binrw_input.as_ref(), 0, &mut st.fields); } syn::Data::Enum(en) => { for (index, variant) in en.variants.iter_mut().enumerate() { clean_struct_attrs(&mut variant.attrs); - clean_field_attrs(&binrw_input, index, &mut variant.fields); + clean_field_attrs(binrw_input.as_ref(), index, &mut variant.fields); } } syn::Data::Union(union) => { diff --git a/binrw_derive/src/named_args/codegen.rs b/binrw_derive/src/named_args/codegen.rs index 02f5b8d3..b1225b36 100644 --- a/binrw_derive/src/named_args/codegen.rs +++ b/binrw_derive/src/named_args/codegen.rs @@ -26,7 +26,7 @@ pub(super) struct Builder<'a> { pub(super) is_write: bool, } -impl<'a> Builder<'a> { +impl Builder<'_> { pub(super) fn generate(&self, define_result: bool) -> TokenStream { let builder_name = self.builder_name; let name = self.result_name;