Repository navigation
build: pin rustfmt in rust-toolchain.toml like clippy - #727
Merged
nihalpasham merged 3 commits intoAug 10, 2026
Merged
Conversation
`cargo fmt --check` is a required gate, but rustfmt was missing from the
component list while clippy -- the other required gate -- was there. A fresh
checkout therefore produced a toolchain that could not run the fmt gate, which
is the opposite of what pinning the toolchain is for.
CI compensated instead of closing the gap, and had already had to copy the
workaround: fmt.yml added the component so `cargo fmt` resolved against the
pinned nightly, and unit-tests.yml added it again for the generated-intrinsics
job, which needs rustfmt because cuda-intrinsics-gen shells out to it when
writing generated sources. Both steps go away now that the toolchain file
carries the component.
Verified the file still resolves and the gate still passes:
$ rustup show active-toolchain
nightly-2026-04-03-x86_64-unknown-linux-gnu (overridden by rust-toolchain.toml)
$ cargo fmt --version
rustfmt 1.9.0-nightly (55e86c9968 2026-04-02)
$ cargo fmt --all -- --check # root
$ (cd crates/rustc-codegen-cuda && cargo fmt --all -- --check) # codegen
Closes NVIDIA#726
Signed-off-by: Vyncint Ng <[email protected]>
Its header demands an exact match with the parent cuda-oxide toolchain, and fmt.yml's formatting job otherwise depends silently on step ordering to have rustfmt present when the nested workspace's toolchain resolves.
…onent Sync the RUST_TOOLCHAIN_TOML scaffold constant with the repository's own pin so generated projects can run `cargo fmt` without a rustup detour.
Collaborator
|
Makes sense, the two CI workarounds deleting cleanly proves the point. I pushed a parity commit:
Closes #726. |
nihalpasham
approved these changes
Aug 10, 2026
nihalpasham
added a commit
that referenced
this pull request
Aug 11, 2026
* docs: sync the book's quoted toolchain pin, and guard every copy #727 added `rustfmt` to `rust-toolchain.toml` and to the nested copy at `crates/rustc-codegen-cuda/rust-toolchain.toml`, but not to the two `[toolchain]` blocks the book quotes. Both still listed five components. Those blocks are presented as the repo's real file -- one is labelled "already in the repo root" -- so a reader copies them into their own project and gets a pin with no `rustfmt`. The symptom then lands somewhere else entirely: `cargo oxide fmt` fails, or `just fmt-check` does, and neither points back at the toolchain file. Nothing catches this. The pin is duplicated three ways and no build compares them: rustup resolves the backend's own `[workspace]` against the nested copy, so a mismatch there fails to load rather than warn, and the book's copies are prose as far as any gate is concerned. The nested file's header already says "Must match the parent cuda-oxide toolchain exactly!", but a comment enforces nothing -- which is how #727 slipped. So this adds `scripts/check-toolchain-parity.sh`, alongside the other source-only consistency guards, and a `toolchain-pin-parity` job in status-guard.yml. It compares channel and components between the two real files and every `[toolchain]` block fenced in the book. Anything else in a block is free to differ, and a block may omit either key: the check is that what a copy does state is right, not that it restates everything. The `rustup component add` command lines are deliberately not covered -- they are not exhaustive, because rustup installs whatever the pin names. The book's bump procedure named only the root file, which is the other half of why this drifted, so it now names the nested copy and the guard. Verified: the guard passes on the corrected tree, and reverting either book page reproduces the real #727 drift with `missing rustfmt` named. Injecting a channel or component change into the nested pin is caught too. `sphinx-build -W --keep-going`, as the book gate runs it, succeeds. Signed-off-by: Vyncint Ng <[email protected]> * ci: extend the toolchain-pin guard to the scaffold, devcontainer, and every dated markdown reference The guard from the previous commit covers the nested pin and the book's two quoted [toolchain] blocks, but "every copy" was still short four: - The RUST_TOOLCHAIN_TOML scaffold in crates/cargo-oxide/src/commands.rs. `cargo oxide new` writes it into every new project as that project's rust-toolchain.toml, so it is the highest-impact copy: a stale scaffold never reddens this repo's CI, it hands each new user a pin whose backend cannot load, and the failure surfaces on their machine. It is a full toolchain file, so both keys are required and must match the root exactly, and the block carries its own parse self-test: a renamed or moved constant fails loudly instead of matching nothing. - The rust feature in .devcontainer/devcontainer.json, parsed as JSON rather than grepped. The version must be the pin's channel. The components line is a deliberate warm-cache subset (the container ships its own LLVM 21 and sets CUDA_OXIDE_LLC, so rustup's llvm-tools is left for rust-toolchain.toml to pull on first use), so it is checked as a subset: anything preinstalled must be a component the pin still names. The feature id is matched exactly with its version tag stripped, so a renamed feature trips the self-test rather than a lookalike (.../rustup) being read as the rust feature. - Every dated nightly reference in tracked markdown, which covers the remaining two named copies (.devcontainer/README.md and the rustup commands in the book's installation page) and every other dated rustup/cargo command and prose mention in one rule: any nightly-YYYY-MM-DD a tracked page spells must be the pinned one. The token itself is the check, so the guard is position-independent and survives pages being reworded, moved, or added; nothing was de-pinned because the dates in `rustup toolchain install` and `cargo +nightly-... install` lines are load-bearing (readers run them outside a checkout, where no rust-toolchain.toml can correct them). Files come from `git ls-files`, the only precise notion of tracked markdown: a bare glob would sweep up untracked trees such as a local target/ full of registry READMEs. Component lists on `rustup component add` lines stay uncovered, as before. The OK summary now counts all five kinds of copy, and the workflow comment and the book's bump procedure no longer undercount them. Verified by mutation: thirteen injected drifts (nested channel and components, scaffold channel, components, and renamed constant, devcontainer version, stale component, and renamed feature, both book blocks, and dated references in installation.md, README.md, and .devcontainer/README.md) each fail naming the drifted copy, and the restored tree is green. shellcheck 0.11.0 is clean, and `sphinx-build -W --keep-going -b html` still succeeds. --------- Signed-off-by: Vyncint Ng <[email protected]> Co-authored-by: nihalpasham <[email protected]>
nihalpasham
added a commit
that referenced
this pull request
Aug 11, 2026
…793) * docs: sync the book's quoted toolchain pin, and guard every copy #727 added `rustfmt` to `rust-toolchain.toml` and to the nested copy at `crates/rustc-codegen-cuda/rust-toolchain.toml`, but not to the two `[toolchain]` blocks the book quotes. Both still listed five components. Those blocks are presented as the repo's real file -- one is labelled "already in the repo root" -- so a reader copies them into their own project and gets a pin with no `rustfmt`. The symptom then lands somewhere else entirely: `cargo oxide fmt` fails, or `just fmt-check` does, and neither points back at the toolchain file. Nothing catches this. The pin is duplicated three ways and no build compares them: rustup resolves the backend's own `[workspace]` against the nested copy, so a mismatch there fails to load rather than warn, and the book's copies are prose as far as any gate is concerned. The nested file's header already says "Must match the parent cuda-oxide toolchain exactly!", but a comment enforces nothing -- which is how #727 slipped. So this adds `scripts/check-toolchain-parity.sh`, alongside the other source-only consistency guards, and a `toolchain-pin-parity` job in status-guard.yml. It compares channel and components between the two real files and every `[toolchain]` block fenced in the book. Anything else in a block is free to differ, and a block may omit either key: the check is that what a copy does state is right, not that it restates everything. The `rustup component add` command lines are deliberately not covered -- they are not exhaustive, because rustup installs whatever the pin names. The book's bump procedure named only the root file, which is the other half of why this drifted, so it now names the nested copy and the guard. Verified: the guard passes on the corrected tree, and reverting either book page reproduces the real #727 drift with `missing rustfmt` named. Injecting a channel or component change into the nested pin is caught too. `sphinx-build -W --keep-going`, as the book gate runs it, succeeds. Signed-off-by: Vyncint Ng <[email protected]> * docs: list every workspace member in README, and guard the inventory `dialect-iket` and `iket-lower` have no row in README's Crate Overview -- 1,700 lines of compiler across two crates, invisible to anyone reading the tree's only map of itself. Both are workspace members with descriptions in their own manifests; they were simply never added. Nothing catches that. No build fails when a crate goes unlisted, and the overview is the only place the members are enumerated for a human, so the omission is silent by construction. `scripts/check-crate-inventory.sh` compares the root manifest's `members` list against the crate rows in that section, joining the other source-only guards and status-guard.yml. Direction is deliberate: every member needs a row, and extra rows are fine. `rustc-codegen-cuda` is not a workspace member -- it carries its own `[workspace]` for the rustc_private dylibs -- and is listed anyway, which is right, because a reader cares about the crate and not about which workspace resolves it. So the guard reports members with no row and never the reverse. Members come from the root Cargo.toml rather than `cargo metadata`: the question is which crates the workspace declares, which is what that list says, and reading it needs no cargo, no lockfile and no network. A glob entry would name crates the guard cannot resolve, so it refuses rather than skipping them silently. Verified: passes on the fixed tree (25 members, all listed); reverting just the README rows reports exactly `dialect-iket` and `iket-lower`; adding a member with no row is caught the same way. Stacked on #790, which adds the sibling toolchain-parity guard to the same workflow file -- review only the second commit. Signed-off-by: Vyncint Ng <[email protected]> --------- Signed-off-by: Vyncint Ng <[email protected]> Co-authored-by: nihalpasham <[email protected]>
nihalpasham
added a commit
that referenced
this pull request
Aug 19, 2026
…tching the pin (#1030) * docs: three docs give three different rustup component lists, none matching the pin The same onboarding step -- install the pinned toolchain and its components -- appears in three places with three different answers, and the pin has a fourth: README.md:183 rust-src rustc-dev llvm-tools [3] book/appendix/building-from-source.md:42 rust-src rustc-dev llvm-tools [3] book/getting-started/installation.md:243 rust-src rustc-dev rust-analyzer llvm-tools [4] rust-toolchain.toml + rust-analyzer clippy rustfmt [6] `cargo oxide new` scaffold the same 6 `rustfmt` and `clippy` are missing from all three, and `rustfmt` is not optional: `cargo oxide fmt` shells out to `cargo fmt`, and `cuda-intrinsics-gen` runs `rustfmt_source` on every file it generates (`generate.rs:35`). #727 added it to the pin for exactly that reason. Inside a checkout none of this bites, because `rust-toolchain.toml` makes rustup install whatever the pin names -- which is why `check-toolchain-parity.sh` deliberately leaves these command lines out of scope ("the `rustup component add` command lines ... are not quotes of it"). But README.md:183 sits directly under `cargo +nightly-2026-04-03 install --git ... cargo-oxide`, which is the out-of-checkout path: there is no `rust-toolchain.toml` there, so rustup installs exactly what the line names and the gap is real. All three now name the pin's six, matching the scaffold `cargo oxide new` writes into user projects. Left alone deliberately -- three narrower lines that name a component because a specific symptom names it, not as the install step: building-from-source.md:265 `rustup component add rustc-dev ...` installation.md:371 `rustup component add llvm-tools ...` for a missing llc installation.md:374 `rustup component add rust-src llvm-tools ...` The devcontainer's five (`llvm-tools` omitted because the image ships LLVM 21 and sets `CUDA_OXIDE_LLC`) is also deliberate and already guarded, so it is unchanged. Verified: all three lines now expand to exactly the pin's component list, compared programmatically against `rust-toolchain.toml`; `just book` (`sphinx-build -W --keep-going`) succeeds; check-toolchain-parity and check-crate-inventory pass. Signed-off-by: Vyncint Ng <[email protected]> * docs(book): account for the three non-build components after the rustup lists --------- Signed-off-by: Vyncint Ng <[email protected]> Co-authored-by: nihalpasham <[email protected]>
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.
Closes #726.
clippywas in the component list;rustfmtwas not — thoughcargo fmt --checkis a required gate exactly like clippy. A fresh checkout produced atoolchain that could not run the fmt gate.
CI compensated instead of closing the gap, and had already copied the
workaround once:
fmt.yml— its comment named the cause outright: "rust-toolchain.toml pinsnightly-2026-04-03 but does not list rustfmt as a component."
unit-tests.yml— thegenerated-intrinsicsjob needs it too, becausecuda-intrinsics-genshells out to rustfmt when writing generated sources.Both steps are removed; the toolchain file now carries the component, so a third
job needing rustfmt gets it for free.
Verified
Both workflow files still parse as YAML. No GPU needed.
If you would rather keep the explicit
rustup component add rustfmtsteps asbelt-and-braces, I am happy to restore them and land only the toolchain change.