From 59bc364a0e71ace4e819a3e5f5048ce2bc388ed4 Mon Sep 17 00:00:00 2001 From: Douman Date: Mon, 22 Jul 2019 18:28:07 +0200 Subject: macros: detect double test attribute (#1336) --- tokio-macros/src/lib.rs | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'tokio-macros') diff --git a/tokio-macros/src/lib.rs b/tokio-macros/src/lib.rs index c036f552..3a7b9ec4 100644 --- a/tokio-macros/src/lib.rs +++ b/tokio-macros/src/lib.rs @@ -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"); -- cgit v1.2.3