mirror of
https://github.com/tokio-rs/tokio.git
synced 2026-08-25 00:00:18 +02:00
macros: Error on function with arguments (#1419)
This commit is contained in:
+13
-1
@@ -61,6 +61,12 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||
compile_error!("the async keyword is missing from the function declaration");
|
||||
};
|
||||
|
||||
return TokenStream::from(tokens);
|
||||
} else if !input.decl.inputs.is_empty() {
|
||||
let tokens = quote_spanned! { input.span() =>
|
||||
compile_error!("the main function cannot accept arguments");
|
||||
};
|
||||
|
||||
return TokenStream::from(tokens);
|
||||
}
|
||||
|
||||
@@ -102,7 +108,7 @@ pub fn main(args: TokenStream, item: TokenStream) -> TokenStream {
|
||||
///
|
||||
/// # Examples
|
||||
///
|
||||
/// ```ignore
|
||||
/// ```no_run
|
||||
/// #![feature(async_await)]
|
||||
///
|
||||
/// #[tokio::test]
|
||||
@@ -134,6 +140,12 @@ pub fn test(_attr: TokenStream, item: TokenStream) -> TokenStream {
|
||||
compile_error!("the async keyword is missing from the function declaration");
|
||||
};
|
||||
|
||||
return TokenStream::from(tokens);
|
||||
} else if !input.decl.inputs.is_empty() {
|
||||
let tokens = quote_spanned! { input.span() =>
|
||||
compile_error!("the test function cannot accept arguments");
|
||||
};
|
||||
|
||||
return TokenStream::from(tokens);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user