Repository navigation
fix(cargo-gpu-install): harden toolchain channel parsing, add tests - #691
Closed
sorinirimies wants to merge 1 commit into
Closed
sorinirimies wants to merge 1 commit into
sorinirimies wants to merge 1 commit into
Conversation
`cargo gpu install` reads the toolchain from `rustc_codegen_spirv/build.rs` by text-matching `channel = "..."`, the same line `cargo xtask` rewrites via regex. It had no tests, so format drift would only surface at install time for users. - Extract the pure `parse_toolchain_channel`; allow leading whitespace, reject an empty channel, clearer errors. - Test it against the real `build.rs`, and that it agrees with `rust-toolchain.toml`.
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.
Summary
cargo gpu installfinds the toolchain by text-matchingchannel = "..."in the checked-outrustc_codegen_spirv/build.rs;cargo xtask update-toolchainrewrites the same line with a regex. Nothing tested that contract, so drift (e.g. indenting the line, orbuild.rsandrust-toolchain.tomldisagreeing) would only show up when users install.The format has to stay readable for older rust-gpu checkouts, so this keeps it and only makes it more lenient.
Evidence
New tests in
spirv_source::test:cargo test -p cargo-gpu-install --features test spirv_source: 9 passed. Clippy-D warningsclean.Merge Danger
Door: two-way
Blast Radius: small — every input the old parser accepted yields the same channel, except
channel = "", which now errors instead of returning an empty string.