diff --git a/tracing-attributes/src/lib.rs b/tracing-attributes/src/lib.rs index 026b998155..86ac3735c5 100644 --- a/tracing-attributes/src/lib.rs +++ b/tracing-attributes/src/lib.rs @@ -288,7 +288,7 @@ fn instrument_speculative( args: InstrumentArgs, item: proc_macro::TokenStream, ) -> proc_macro::TokenStream { - let input = syn::parse_macro_input!(item as MaybeItemFn); + let input = syn::parse_macro_input!(item as MaybeItemFn); let instrumented_function_name = input.sig.ident.to_string(); gen_function( &input.as_ref(), @@ -649,19 +649,6 @@ fn gen_block( ) } -#[derive(Debug, Clone)] -struct MaybeBlock(TokenStream); - -impl ToTokens for MaybeBlock { - fn to_tokens(&self, tokens: &mut TokenStream) { - self.0.to_tokens(tokens) - } - - fn into_token_stream(self) -> TokenStream { - self.0.into_token_stream() - } -} - #[derive(Debug, Clone)] struct MaybeItemFn { attrs: Vec, @@ -670,17 +657,17 @@ struct MaybeItemFn { block: B, } -impl MaybeItemFn { - fn new(attrs: Vec, vis: Visibility, sig: Signature, block: TokenStream) -> Self { +impl MaybeItemFn { + fn new(attrs: Vec, vis: Visibility, sig: Signature, block: B) -> Self { Self { attrs, vis, sig, - block: MaybeBlock(block), + block, } } - fn as_ref(&self) -> MaybeItemFnRef<'_, MaybeBlock> { + fn as_ref(&self) -> MaybeItemFnRef<'_, B> { MaybeItemFnRef { attrs: &self.attrs, vis: &self.vis, @@ -690,7 +677,7 @@ impl MaybeItemFn { } } -impl Parse for MaybeItemFn { +impl Parse for MaybeItemFn { fn parse(input: ParseStream<'_>) -> syn::Result { let attrs = input.call(syn::Attribute::parse_outer)?; let vis: Visibility = input.parse()?;