Fix assorted Clippy lints (#3390)

This commit is contained in:
Dennis Kobert
2025-11-17 08:58:31 +01:00
committed by GitHub
parent ebb434692a
commit 181c30bc0a
30 changed files with 669 additions and 694 deletions

View File

@@ -50,14 +50,12 @@ impl BasicItem {
let token: LitStr = attribute.parse_args()?;
self.icon = Some(token.value());
}
if attribute.path().is_ident("doc") {
if let Meta::NameValue(meta_name_value) = &attribute.meta {
if let Expr::Lit(el) = &meta_name_value.value {
if let syn::Lit::Str(token) = &el.lit {
self.description = Some(token.value());
}
}
}
if attribute.path().is_ident("doc")
&& let Meta::NameValue(meta_name_value) = &attribute.meta
&& let Expr::Lit(el) = &meta_name_value.value
&& let syn::Lit::Str(token) = &el.lit
{
self.description = Some(token.value());
}
Ok(())
}

View File

@@ -530,10 +530,10 @@ fn parse_field(pat_ident: PatIdent, ty: Type, attrs: &[Attribute]) -> syn::Resul
})
})
.transpose()?;
if let Some(range) = &number_mode_range {
if range.elems.len() != 2 {
return Err(Error::new_spanned(range, "Expected a tuple of two values for `range` for the min and max, respectively"));
}
if let Some(range) = &number_mode_range
&& range.elems.len() != 2
{
return Err(Error::new_spanned(range, "Expected a tuple of two values for `range` for the min and max, respectively"));
}
let unit = extract_attribute(attrs, "unit")
@@ -641,20 +641,19 @@ fn parse_field(pat_ident: PatIdent, ty: Type, attrs: &[Attribute]) -> syn::Resul
fn parse_node_type(ty: &Type) -> (bool, Option<Type>, Option<Type>) {
if let Type::ImplTrait(impl_trait) = ty {
for bound in &impl_trait.bounds {
if let syn::TypeParamBound::Trait(trait_bound) = bound {
if trait_bound.path.segments.last().is_some_and(|seg| seg.ident == "Node") {
if let syn::PathArguments::AngleBracketed(args) = &trait_bound.path.segments.last().unwrap().arguments {
let input_type = args.args.iter().find_map(|arg| if let syn::GenericArgument::Type(ty) = arg { Some(ty.clone()) } else { None });
let output_type = args.args.iter().find_map(|arg| {
if let syn::GenericArgument::AssocType(assoc_type) = arg {
if assoc_type.ident == "Output" { Some(assoc_type.ty.clone()) } else { None }
} else {
None
}
});
return (true, input_type, output_type);
if let syn::TypeParamBound::Trait(trait_bound) = bound
&& trait_bound.path.segments.last().is_some_and(|seg| seg.ident == "Node")
&& let syn::PathArguments::AngleBracketed(args) = &trait_bound.path.segments.last().unwrap().arguments
{
let input_type = args.args.iter().find_map(|arg| if let syn::GenericArgument::Type(ty) = arg { Some(ty.clone()) } else { None });
let output_type = args.args.iter().find_map(|arg| {
if let syn::GenericArgument::AssocType(assoc_type) = arg {
if assoc_type.ident == "Output" { Some(assoc_type.ty.clone()) } else { None }
} else {
None
}
}
});
return (true, input_type, output_type);
}
}
}