diff --git a/components/salsa-2022-macros/src/db.rs b/components/salsa-2022-macros/src/db.rs index b6fe5720..62ae6ad9 100644 --- a/components/salsa-2022-macros/src/db.rs +++ b/components/salsa-2022-macros/src/db.rs @@ -55,10 +55,10 @@ impl syn::parse::Parse for Args { } fn find_storage_field(input: &syn::ItemStruct) -> Result { - let storage = format!("storage"); + let storage = "storage"; for field in input.fields.iter() { if let Some(i) = &field.ident { - if i.to_string() == storage { + if i == storage { return Ok(i.clone()); } } else { diff --git a/components/salsa-2022-macros/src/tracked_fn.rs b/components/salsa-2022-macros/src/tracked_fn.rs index 0af8393d..9e05c77f 100644 --- a/components/salsa-2022-macros/src/tracked_fn.rs +++ b/components/salsa-2022-macros/src/tracked_fn.rs @@ -12,7 +12,7 @@ pub(crate) fn tracked( let args = syn::parse_macro_input!(args as Args); match tracked_fn(args, item_fn) { Ok(p) => p.into(), - Err(e) => return e.into_compile_error().into(), + Err(e) => e.into_compile_error().into(), } } @@ -145,7 +145,7 @@ fn fn_configuration(args: &Args, item_fn: &syn::ItemFn) -> Configuration { let fn_ty = item_fn.sig.ident.clone(); - let indices = (0..item_fn.sig.inputs.len() - 1).map(|i| Literal::usize_unsuffixed(i)); + let indices = (0..item_fn.sig.inputs.len() - 1).map(Literal::usize_unsuffixed); let (cycle_strategy, recover_fn) = if let Some(recovery_fn) = &args.recovery_fn { // Create the `recover_from_cycle` function, which (a) maps from the interned id to the actual // keys and then (b) invokes the recover function itself. @@ -181,7 +181,7 @@ fn fn_configuration(args: &Args, item_fn: &syn::ItemFn) -> Configuration { // Create the `execute` function, which (a) maps from the interned id to the actual // keys and then (b) invokes the function itself (which we embed within). - let indices = (0..item_fn.sig.inputs.len() - 1).map(|i| Literal::usize_unsuffixed(i)); + let indices = (0..item_fn.sig.inputs.len() - 1).map(Literal::usize_unsuffixed); let execute_fn = parse_quote! { fn execute(__db: &salsa::function::DynDb, __id: Self::Key) -> Self::Value { #inner_fn @@ -487,9 +487,7 @@ fn make_fn_return_ref(mut ref_getter_fn: syn::ItemFn) -> syn::Result syn::Result<(syn::Lifetime, &syn::Type)> { match &mut func.sig.inputs[0] { - syn::FnArg::Receiver(r) => { - return Err(syn::Error::new(r.span(), "expected database, not self")) - } + syn::FnArg::Receiver(r) => Err(syn::Error::new(r.span(), "expected database, not self")), syn::FnArg::Typed(pat_ty) => match &mut *pat_ty.ty { syn::Type::Reference(ty) => match &ty.lifetime { Some(lt) => Ok((lt.clone(), &pat_ty.ty)), @@ -517,12 +515,10 @@ fn db_lifetime_and_ty(func: &mut syn::ItemFn) -> syn::Result<(syn::Lifetime, &sy Ok((db_lifetime, &pat_ty.ty)) } }, - _ => { - return Err(syn::Error::new( - pat_ty.span(), - "expected database to be a `&` type", - )) - } + _ => Err(syn::Error::new( + pat_ty.span(), + "expected database to be a `&` type", + )), }, } } @@ -574,7 +570,7 @@ fn accumulated_fn( /// * the name(s) of the key arguments fn fn_args(item_fn: &syn::ItemFn) -> syn::Result<(proc_macro2::Ident, Vec)> { // Check that we have no receiver and that all argments have names - if item_fn.sig.inputs.len() == 0 { + if item_fn.sig.inputs.is_empty() { return Err(syn::Error::new( item_fn.sig.span(), "method needs a database argument", diff --git a/components/salsa-2022-macros/src/tracked_struct.rs b/components/salsa-2022-macros/src/tracked_struct.rs index 5212e5b0..3bc47ae6 100644 --- a/components/salsa-2022-macros/src/tracked_struct.rs +++ b/components/salsa-2022-macros/src/tracked_struct.rs @@ -279,14 +279,14 @@ impl TrackedStruct { /// of the function ingredients within that tuple. fn value_field_indices(&self) -> Vec { (0..self.value_fields().count()) - .map(|i| Literal::usize_unsuffixed(i)) + .map(Literal::usize_unsuffixed) .collect() } /// Indices of each of the id fields fn id_field_indices(&self) -> Vec { (0..self.id_fields().count()) - .map(|i| Literal::usize_unsuffixed(i)) + .map(Literal::usize_unsuffixed) .collect() } }