From 5fb698ab62495d064e5847839807a47a5f912207 Mon Sep 17 00:00:00 2001 From: David Tolnay Date: Thu, 26 Dec 2024 18:24:14 -0800 Subject: [PATCH] Resolve useless_conversion clippy lint warning: useless conversion to the same type: `syn::Attribute` --> src/derive.rs:34:21 | 34 | .into_iter() | _____________________^ | |_____________________| 35 | || .map(std::convert::Into::into) | ||______________________________________^ 36 | | .collect(); | |_________- help: consider removing | = help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#useless_conversion = note: `-W clippy::useless-conversion` implied by `-W clippy::all` = help: to override `-W clippy::all` add `#[allow(clippy::useless_conversion)]` --- src/derive.rs | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) diff --git a/src/derive.rs b/src/derive.rs index 428ab92..fdcd151 100644 --- a/src/derive.rs +++ b/src/derive.rs @@ -29,12 +29,6 @@ fn derive2(input: TokenStream, run: fn(Execution)) -> TokenStream { } fn syn_to_type(input: DeriveInput) -> Type { - let attrs: Vec<_> = input - .attrs - .into_iter() - .map(std::convert::Into::into) - .collect(); - Type(TypeNode::DataStructure { name: Ident::from(input.ident), generics: Generics::syn_to_generics(input.generics), @@ -50,7 +44,7 @@ fn syn_to_type(input: DeriveInput) -> Type { element: Type::syn_to_type(field.ty), }) .collect(), - attrs, + attrs: input.attrs, })), syn::Fields::Unnamed(fields) => Data::Struct(Struct::Tuple(TupleStruct { fields: fields @@ -63,15 +57,15 @@ fn syn_to_type(input: DeriveInput) -> Type { element: Type::syn_to_type(field.ty), }) .collect(), - attrs, + attrs: input.attrs, })), - syn::Fields::Unit => Data::Struct(Struct::Unit(UnitStruct { attrs })), + syn::Fields::Unit => Data::Struct(Struct::Unit(UnitStruct { attrs: input.attrs })), }, syn::Data::Enum(data) => { // FIXME convert enum variants Data::Enum(Enum { variants: Vec::new(), - attrs, + attrs: input.attrs, }) } syn::Data::Union(_) => unimplemented!("union"),