macros: fix wrong error messages (#4067)

This commit is contained in:
Fedorenko Dmitrij
2021-08-25 19:59:41 +02:00
committed by GitHub
parent 51f4f0594c
commit 80bda3bf5f
7 changed files with 56 additions and 38 deletions
+14 -2
View File
@@ -323,15 +323,27 @@ fn parse_knobs(
let body = &input.block;
let brace_token = input.block.brace_token;
let (tail_return, tail_semicolon) = match body.stmts.last() {
Some(syn::Stmt::Semi(expr, _)) => (
match expr {
syn::Expr::Return(_) => quote! { return },
_ => quote! {},
},
quote! {
;
},
),
_ => (quote! {}, quote! {}),
};
input.block = syn::parse2(quote_spanned! {last_stmt_end_span=>
{
let body = async #body;
#[allow(clippy::expect_used)]
#rt
#tail_return #rt
.enable_all()
.build()
.expect("Failed building the Runtime")
.block_on(body)
.block_on(body)#tail_semicolon
}
})
.expect("Parsing failure");