Skip to content

Commit 373b121

Browse files
fix: use full macro path (#2028)
When the `#[sqlx::test]` macro is imported using `#[macro_use]` such as in the following example: ```rust extern crate sqlx; mod tests { #[test] fn something() {} } ``` then the `#[test]` generated by the macro will refer to itself instead of the standard Rust `#[test]` macro. This will cause `rustc` to recursively expand it and produce the following error message: ``` thread 'rustc' has overflowed its stack fatal runtime error: stack overflow ``` Instead, we can just refer to the standard macro by using its fully qualified path. This PR: * Swaps `#[test]` usages in `#[sqlx::test]` for their hygenic path to prevent recursive expansion alongside `#[macro_use]` Closes #2017.
1 parent c4f1816 commit 373b121

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

sqlx-macros/src/test_attr.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ fn expand_simple(input: syn::ItemFn) -> TokenStream {
5252
let attrs = &input.attrs;
5353

5454
quote! {
55-
#[test]
55+
#[::core::prelude::v1::test]
5656
#(#attrs)*
5757
fn #name() #ret {
5858
::sqlx::test_block_on(async { #body })
@@ -105,7 +105,7 @@ fn expand_advanced(args: syn::AttributeArgs, input: syn::ItemFn) -> crate::Resul
105105
};
106106

107107
Ok(quote! {
108-
#[test]
108+
#[::core::prelude::v1::test]
109109
#(#attrs)*
110110
fn #name() #ret {
111111
async fn inner(#inputs) #ret {

0 commit comments

Comments
 (0)