mirror of
https://github.com/GraphiteEditor/Graphite.git
synced 2026-09-15 22:28:10 +08:00
Fix assorted Clippy lints (#3390)
This commit is contained in:
@@ -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(())
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user