diff --git a/tracing-attributes/src/lib.rs b/tracing-attributes/src/lib.rs index fe7df2dbe3..2900a8eb07 100644 --- a/tracing-attributes/src/lib.rs +++ b/tracing-attributes/src/lib.rs @@ -403,8 +403,8 @@ fn instrument_handle_recent_async_trait( } // given an existing function, generate an instrumented version of that function -fn gen_function<'a>( - input: &'a ItemFn, +fn gen_function( + input: &ItemFn, mut args: InstrumentArgs, instrumented_function_name: String, variables_rebindings: Vec<(Ident, Ident)>, @@ -557,7 +557,7 @@ fn gen_block<'a>( // eplace every use of a variable by its original name if let Some(Fields(ref mut fields)) = args.fields { let mut replacer = KnifeReplacer { - idents: param_names.clone(), + idents: param_names, types: Vec::new(), }; @@ -1159,6 +1159,9 @@ struct KnifeReplacer<'a> { impl<'a> syn::visit_mut::VisitMut for KnifeReplacer<'a> { fn visit_ident_mut(&mut self, id: &mut Ident) { for (old_ident, new_ident) in &self.idents { + // we deliberately compare strings because we want to ignore the spans + // If we apply clippy's lint, the behavior changes + #[allow(clippy::cmp_owned)] if id.to_string() == old_ident.to_string() { *id = new_ident.clone(); }