Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: use hygenic macro path #2028

Merged

Conversation

alexander-jackson
Copy link
Contributor

When the #[sqlx::test] macro is imported using #[macro_use] such as in the following example:

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.

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 launchbadge#2017.
@abonander abonander merged commit 373b121 into launchbadge:main Aug 10, 2022
@alexander-jackson alexander-jackson deleted the fix/use-hygenic-macro-path branch September 9, 2022 19:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

#[sqlx::test] imported with #[macro_use] causes a stack overflow in rustc
2 participants