Repository navigation
fix(macros-core): only track paths rustc can checksum - #4439
Merged
Merged
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
With
--cfg sqlx_macros_unstable,MtimeCacheBuilder::add_pathpasses every watched path toproc_macro::tracked::path. Some of those paths are not files:query/metadata.rs::load_env, each directory searched for.envthat has no.envis registered as the directory itself. fix(macros): don't look for.envoutside workspace聽#4282 bounds that walk to the workspace, but it still registers directories.<manifest_dir>/sqlx.tomlis registered even when it doesn't exist.rustc can't checksum a directory or a missing file. Under cargo's
-Z checksum-freshnessit logsfailed to compute checksum, omitting it from dep-info ... Is a directory (os error 21). The resulting dep-info entry has no checksum, so cargo considers the crate permanently dirty: it is recompiled on every build, even a no-op one.That blocks the main reason to combine
sqlx_macros_unstablewith checksum-freshness: letting cargo rebuild a crate exactly when one of its.sqlx/query-*.jsonfiles changes.Fix
Call
proc_macro::tracked::pathonly whenpath.is_file(). The in-processMtimeCachestill records every path, so its own invalidation is unchanged. The only cost is that rustc is no longer told about a.envorsqlx.tomlthat doesn't exist yet, so creating one later won't by itself trigger a rebuild. Before this change that case caused a rebuild on every build anyway.Verification
I tested a single-crate project with one
query!, built offline (SQLX_OFFLINE=true), usingRUSTFLAGS="--cfg sqlx_macros_unstable"andCARGO_UNSTABLE_CHECKSUM_FRESHNESS=trueon a 2026-09-22 nightly, withsqlx-macros-core0.9.0 patched via[patch.crates-io]:.sqlxJSON editedWithout
sqlx_macros_unstable, the patched code is compiled out and behaviour is unchanged.