Skip to content

Commit e40b5f9

Browse files
ibraheemdevtaiki-e
andcommitted
Apply suggestions from code review
Co-authored-by: Taiki Endo <te316e89@gmail.com>
1 parent 5180351 commit e40b5f9

File tree

1 file changed

+9
-5
lines changed

1 file changed

+9
-5
lines changed

futures-macro/src/executor.rs

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +1,29 @@
11
use proc_macro::TokenStream;
22
use quote::quote;
33

4-
pub(crate) fn test(_: TokenStream, item: TokenStream) -> TokenStream {
4+
pub(crate) fn test(args: TokenStream, item: TokenStream) -> TokenStream {
5+
if !args.is_empty() {
6+
return syn::Error::new_spanned(args, "invalid argument"))
7+
.to_compile_error()
8+
.into();
9+
}
510
let mut input = syn::parse_macro_input!(item as syn::ItemFn);
611
let attrs = &input.attrs;
712
let vis = &input.vis;
813
let sig = &mut input.sig;
914
let body = &input.block;
1015

11-
if sig.asyncness.is_none() {
16+
if sig.asyncness.take().is_none() {
1217
return syn::Error::new_spanned(sig.fn_token, "Only async functions are supported")
1318
.to_compile_error()
1419
.into();
1520
}
1621

17-
sig.asyncness = None;
18-
1922
let gen = quote! {
23+
#[::core::prelude::v1::test]
2024
#(#attrs)*
2125
#vis #sig {
22-
::futures_test::__private::block_on(async move { #body })
26+
::futures_test::__private::block_on(async move #body)
2327
}
2428
};
2529

0 commit comments

Comments
 (0)