mirror of
https://github.com/servo/servo.git
synced 2025-07-22 14:53:49 +01:00
Fix all clippy warnings in style_derive
This commit is contained in:
parent
d5c1690cb4
commit
dd301c084d
4 changed files with 12 additions and 14 deletions
|
@ -29,7 +29,7 @@ where
|
|||
});
|
||||
s.each_variant(|variant| {
|
||||
let (mapped, mapped_fields) = value(variant, "mapped");
|
||||
let fields_pairs = variant.bindings().into_iter().zip(mapped_fields);
|
||||
let fields_pairs = variant.bindings().iter().zip(mapped_fields);
|
||||
let mut computations = quote!();
|
||||
computations.append_all(fields_pairs.map(|(field, mapped_field)| {
|
||||
let expr = f(field.clone());
|
||||
|
@ -237,7 +237,7 @@ pub fn ref_pattern<'a>(
|
|||
v.bindings_mut().iter_mut().for_each(|b| {
|
||||
b.binding = Ident::new(&format!("{}_{}", b.binding, prefix), Span::call_site())
|
||||
});
|
||||
(v.pat(), v.bindings().iter().cloned().collect())
|
||||
(v.pat(), v.bindings().to_vec())
|
||||
}
|
||||
|
||||
pub fn value<'a>(variant: &'a VariantInfo, prefix: &str) -> (TokenStream, Vec<BindingInfo<'a>>) {
|
||||
|
@ -246,7 +246,7 @@ pub fn value<'a>(variant: &'a VariantInfo, prefix: &str) -> (TokenStream, Vec<Bi
|
|||
b.binding = Ident::new(&format!("{}_{}", b.binding, prefix), Span::call_site())
|
||||
});
|
||||
v.bind_with(|_| BindStyle::Move);
|
||||
(v.pat(), v.bindings().iter().cloned().collect())
|
||||
(v.pat(), v.bindings().to_vec())
|
||||
}
|
||||
|
||||
/// Transforms "FooBar" to "foo-bar".
|
||||
|
|
|
@ -36,7 +36,7 @@ pub fn derive(input: DeriveInput) -> TokenStream {
|
|||
let identifier = cg::to_css_identifier(
|
||||
&css_variant_attrs
|
||||
.keyword
|
||||
.unwrap_or(variant.ast().ident.to_string()),
|
||||
.unwrap_or_else(|| variant.ast().ident.to_string()),
|
||||
);
|
||||
let ident = &variant.ast().ident;
|
||||
|
||||
|
@ -56,7 +56,7 @@ pub fn derive(input: DeriveInput) -> TokenStream {
|
|||
None => return body,
|
||||
};
|
||||
|
||||
for alias in aliases.split(",") {
|
||||
for alias in aliases.split(',') {
|
||||
body = quote! {
|
||||
#body
|
||||
#alias #condition => Ok(#name::#ident),
|
||||
|
|
|
@ -40,12 +40,12 @@ pub fn derive(mut input: DeriveInput) -> TokenStream {
|
|||
continue;
|
||||
}
|
||||
if let Some(aliases) = parse_attrs.aliases {
|
||||
for alias in aliases.split(",") {
|
||||
for alias in aliases.split(',') {
|
||||
values.push(alias.to_string());
|
||||
}
|
||||
}
|
||||
if let Some(other_values) = info_attrs.other_values {
|
||||
for value in other_values.split(",") {
|
||||
for value in other_values.split(',') {
|
||||
values.push(value.to_string());
|
||||
}
|
||||
}
|
||||
|
@ -61,10 +61,8 @@ pub fn derive(mut input: DeriveInput) -> TokenStream {
|
|||
}
|
||||
if let Some(function) = css_attrs.function {
|
||||
values.push(function.explicit().unwrap_or_else(variant_name));
|
||||
} else {
|
||||
if !derive_struct_fields(&v.fields, &mut types, &mut values) {
|
||||
values.push(variant_name());
|
||||
}
|
||||
} else if !derive_struct_fields(&v.fields, &mut types, &mut values) {
|
||||
values.push(variant_name());
|
||||
}
|
||||
}
|
||||
},
|
||||
|
@ -79,7 +77,7 @@ pub fn derive(mut input: DeriveInput) -> TokenStream {
|
|||
|
||||
let info_attrs = cg::parse_input_attrs::<ValueInfoInputAttrs>(&input);
|
||||
if let Some(other_values) = info_attrs.other_values {
|
||||
for value in other_values.split(",") {
|
||||
for value in other_values.split(',') {
|
||||
values.push(value.to_string());
|
||||
}
|
||||
}
|
||||
|
@ -143,7 +141,7 @@ fn derive_struct_fields<'a>(
|
|||
types.extend(fields.filter_map(|field| {
|
||||
let info_attrs = cg::parse_field_attrs::<ValueInfoFieldAttrs>(field);
|
||||
if let Some(other_values) = info_attrs.other_values {
|
||||
for value in other_values.split(",") {
|
||||
for value in other_values.split(',') {
|
||||
values.push(value.to_string());
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,7 +28,7 @@ pub fn derive(mut input: syn::DeriveInput) -> TokenStream {
|
|||
return Some(quote! { Err(()) });
|
||||
}
|
||||
let (mapped, mapped_bindings) = cg::value(variant, "mapped");
|
||||
let bindings_pairs = variant.bindings().into_iter().zip(mapped_bindings);
|
||||
let bindings_pairs = variant.bindings().iter().zip(mapped_bindings);
|
||||
let mut computations = quote!();
|
||||
computations.append_all(bindings_pairs.map(|(binding, mapped_binding)| {
|
||||
let field_attrs = cg::parse_field_attrs::<AnimationFieldAttrs>(&binding.ast());
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue