From 216dcdec73da98044daa76ee429512655e2e8c05 Mon Sep 17 00:00:00 2001 From: Yoshua Wuyts Date: Sat, 29 Jun 2019 00:04:10 +0200 Subject: [PATCH] attr names Signed-off-by: Yoshua Wuyts --- async-log-attributes/src/lib.rs | 18 +++++------------- src/backtrace.rs | 1 + 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/async-log-attributes/src/lib.rs b/async-log-attributes/src/lib.rs index a03e7e2..13dc239 100644 --- a/async-log-attributes/src/lib.rs +++ b/async-log-attributes/src/lib.rs @@ -21,7 +21,6 @@ use quote::quote; /// Ok(()) /// } /// ``` -#[cfg(not(test))] // NOTE: exporting main breaks tests, we should file an issue. #[proc_macro_attribute] pub fn span_wrap(_attr: TokenStream, item: TokenStream) -> TokenStream { let input = syn::parse_macro_input!(item as syn::ItemFn); @@ -50,17 +49,10 @@ pub fn span_wrap(_attr: TokenStream, item: TokenStream) -> TokenStream { let names: String = args .iter() .enumerate() - .map(|(i, _arg)| match i { - 0 => { - let mut string = format!("arg_{}", 0); - string.push_str("={}"); - string - } - n => { - let mut string = format!(", arg_{}", n); - string.push_str("={}"); - string - } + .map(|(i, _arg)| { + let mut string = format!(", arg_{}", i); + string.push_str("={}"); + string }) .collect(); @@ -68,7 +60,7 @@ pub fn span_wrap(_attr: TokenStream, item: TokenStream) -> TokenStream { #(#attrs)* #vis #constness #unsafety #asyncness #abi fn #generics #name(#(#inputs)*) #output { let __name = format!("{}#{}", file!(), stringify!(#name)); - let __args = format!("{} {}", __name, format_args!(#names, #(#args)*)); + let __args = format!("{}{}", __name, format_args!(#names, #(#args)*)); async_log::span!(__args, { #(#body)* }) diff --git a/src/backtrace.rs b/src/backtrace.rs index 2b81811..a935576 100644 --- a/src/backtrace.rs +++ b/src/backtrace.rs @@ -10,6 +10,7 @@ pub(crate) struct Symbol { /// /// `depth` is how many frames we should look past finding the method where this was called. /// This might require a bit of wrangling to find. +#[allow(unused_attributes)] #[no_mangle] pub(crate) fn async_log_capture_caller(depth: u8) -> Option { let mut count = 0;