From 18833a8e6709c3489ea8f401f1a9d9a28ae20226 Mon Sep 17 00:00:00 2001 From: Douman Date: Fri, 9 Aug 2019 17:04:41 +0200 Subject: [PATCH] macros: Error on function with arguments (#1419) --- tokio-macros/src/lib.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs index b7279b1ee..ccb6ae7d5 100644 --- a/tokio-macros/src/lib.rs +++ b/tokio-macros/src/lib.rs @@ -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); }