Skip to content

Commit f2bd4ee

Browse files
author
Joe Grund
committed
Detect out of order issues
Signed-off-by: Joe Grund <[email protected]>
1 parent a2af155 commit f2bd4ee

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

commandeer-macros/src/lib.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,5 +106,16 @@ pub fn commandeer(args: TokenStream, input: TokenStream) -> TokenStream {
106106

107107
input_fn.block.stmts = new_stmts;
108108

109+
let body_str = quote!(#input_fn).to_string();
110+
111+
if body_str.contains("local_serial_core") {
112+
return syn::Error::new_spanned(
113+
input_fn.sig.fn_token,
114+
"Out of order error. `commandeer` macro must be above the `serial_test` macro.",
115+
)
116+
.to_compile_error()
117+
.into();
118+
}
119+
109120
TokenStream::from(quote! { #input_fn })
110121
}

0 commit comments

Comments
 (0)