macros: Error on function with arguments (#1419)

This commit is contained in:
Douman
2019-08-09 11:04:41 -04:00
committed by Lucio Franco
parent eba8bf2b4b
commit 18833a8e67
+13 -1
View File
@@ -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);
}