Skip to content

Commit

Permalink
Resolve useless_conversion clippy lint
Browse files Browse the repository at this point in the history
    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)]`
  • Loading branch information
dtolnay committed Dec 27, 2024
1 parent 2905477 commit 5fb698a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions src/derive.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand All @@ -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
Expand All @@ -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"),
Expand Down

0 comments on commit 5fb698a

Please sign in to comment.