macros: detect double test attribute (#1336)

This commit is contained in:
Douman
2019-07-22 09:28:07 -07:00
committed by Carl Lerche
parent e88d10a3cb
commit 59bc364a0e
+10
View File
@@ -121,6 +121,16 @@ pub fn test(_attr: TokenStream, item: TokenStream) -> TokenStream {
let body = &input.block;
let attrs = &input.attrs;
for attr in attrs {
if attr.path.is_ident("test") {
let tokens = quote_spanned! { input.span() =>
compile_error!("second test attribute is supplied");
};
return TokenStream::from(tokens);
}
}
if input.asyncness.is_none() {
let tokens = quote_spanned! { input.span() =>
compile_error!("the async keyword is missing from the function declaration");