async-await: add current_thread::Runtime::block_on_async (#1072)

This function is used by the Tokio macros introduced by #1058  but was
omitted from the PR.
This commit is contained in:
Carl Lerche
2019-04-30 19:55:22 -07:00
committed by GitHub
parent 219f24cbf1
commit 4ef736b9d5
8 changed files with 73 additions and 15 deletions
+2
View File
@@ -58,6 +58,7 @@ pub fn test(_attr: TokenStream, item: TokenStream) -> TokenStream {
let ret = &input.decl.output;
let name = &input.ident;
let body = &input.block;
let attrs = &input.attrs;
if input.asyncness.is_none() {
let tokens = quote_spanned! { input.span() =>
@@ -69,6 +70,7 @@ pub fn test(_attr: TokenStream, item: TokenStream) -> TokenStream {
let result = quote! {
#[test]
#(#attrs)*
fn #name() #ret {
let mut rt = tokio::runtime::current_thread::Runtime::new().unwrap();
rt.block_on_async(async { #body })