diff --git a/tokio-macros/src/entry.rs b/tokio-macros/src/entry.rs index 84222dfa504..3b57fcb5a6f 100644 --- a/tokio-macros/src/entry.rs +++ b/tokio-macros/src/entry.rs @@ -328,7 +328,7 @@ fn parse_knobs(mut input: syn::ItemFn, is_test: bool, config: FinalConfig) -> To input.sig.asyncness = None; // If type mismatch occurs, the current rustc points to the last statement. - let (last_stmt_start_span, _last_stmt_end_span) = { + let (last_stmt_start_span, last_stmt_end_span) = { let mut last_stmt = input .block .stmts @@ -375,7 +375,9 @@ fn parse_knobs(mut input: syn::ItemFn, is_test: bool, config: FinalConfig) -> To let body = &input.block; let brace_token = input.block.brace_token; - let body_ident = quote! { body }; + let body_ident = quote_spanned! {last_stmt_end_span=> + body + }; let block_expr = quote_spanned! {Span::call_site()=> #[allow(clippy::expect_used, clippy::diverging_sub_expression)] {