From e10ffa21ec2816ff953b130d34c399f507517ae2 Mon Sep 17 00:00:00 2001 From: Soham Chowdhury Date: Wed, 12 Apr 2023 22:16:09 +0200 Subject: [PATCH] fix: try to repair messages with incorrect bodies --- tokio-macros/src/entry.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) 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)] {