Skip to content

fix(macros-core): update unstable proc_macro APIs for recent nightly#4227

Merged
abonander merged 1 commit intolaunchbadge:mainfrom
barry3406:fix/sqlx-macros-unstable-nightly
Apr 14, 2026
Merged

fix(macros-core): update unstable proc_macro APIs for recent nightly#4227
abonander merged 1 commit intolaunchbadge:mainfrom
barry3406:fix/sqlx-macros-unstable-nightly

Conversation

@barry3406
Copy link
Copy Markdown
Contributor

Does your PR solve an issue?

fixes #4150

Is this a breaking change?

No. The change only touches code gated behind #[cfg(any(sqlx_macros_unstable, procmacro2_semver_exempt))], which is opt-in and only compiles on nightly.


The unstable proc_macro tracking APIs were restructured in rust-lang/rust#149400:

  • modules tracked_env and tracked_path were merged into a single module tracked
  • proc_macro::tracked_env::varproc_macro::tracked::env_var (note: also renamed from var to env_var)
  • proc_macro::tracked_path::pathproc_macro::tracked::path
  • features track_pathproc_macro_tracked_path (+ proc_macro_tracked_env)

Building sqlx-macros-core with --cfg=sqlx_macros_unstable on recent nightly fails for two reasons:

  1. The renames above.
  2. extern crate proc_macro; was declared only in migrate.rs, so proc_macro was not in scope from lib.rs (line 99) or query/cache.rs (line 74). The reporter only saw the rename error because the missing-crate error happens later in the compilation order.

This PR moves the gated extern crate proc_macro; to the crate root in lib.rs (so it's visible to all modules), drops the duplicate from migrate.rs, and updates the four API call sites plus the clippy.toml reason field.

Verified locally on nightly-2026-04-02:

RUSTFLAGS='--cfg=sqlx_macros_unstable' cargo +nightly check -p sqlx-macros-core
    Finished `dev` profile [unoptimized + debuginfo] target(s)

Stable also unaffected.

Drafted with AI assistance. I reviewed every change, reproduced the bug locally on nightly, and verified the fix.

The unstable proc_macro tracking APIs were restructured in
rust-lang/rust#149400:

- modules `tracked_env` and `tracked_path` were merged into a
  single module `tracked`
- `proc_macro::tracked_env::var` -> `proc_macro::tracked::env_var`
- `proc_macro::tracked_path::path` -> `proc_macro::tracked::path`
- features `track_path` -> `proc_macro_tracked_path` (+
  `proc_macro_tracked_env`)

Building with --cfg=sqlx_macros_unstable on recent nightly fails
because of the renames and because `extern crate proc_macro;` was
only declared in `migrate.rs`, leaving `lib.rs` and
`query/cache.rs` without the crate in scope.

Move the gated `extern crate proc_macro;` to the crate root, drop
the duplicate from migrate.rs, and update the API call sites and
the clippy.toml reason field.

Fixes launchbadge#4150
@abonander
Copy link
Copy Markdown
Collaborator

Hopefully this means these APIs are on-track to being stabilized. It's been years.

@abonander abonander merged commit d3a8244 into launchbadge:main Apr 14, 2026
147 checks passed
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.

--cfg=sqlx_macros_unstable broken in recent rust nightly

2 participants