Repository navigation
Rust: Keep custom-named nightly toolchains - #23233
Open
coleleavitt wants to merge 1 commit into
Open
coleleavitt wants to merge 1 commit into
coleleavitt wants to merge 1 commit into
Conversation
`select_toolchain` decided whether the project toolchain is a nightly from its rustup name alone, so a nightly installed under another name (for example with `rustup toolchain link`) was replaced with the fixed stable toolchain. With nightly-only flags such as `-Z` in the Cargo config, the stable compiler then rejects every rustc invocation, `cargo metadata` fails, and macro expansion fails across the whole project. Also treat the toolchain as a nightly when `rustc --version` reports a `-nightly` or `-dev` build, and apply the minimum nightly date to such toolchains using the commit date from the version string.
Contributor
There was a problem hiding this comment.
🟡 Changes recommended
The version probe can inspect an unrelated rustc on PATH instead of the active rustup toolchain, causing incorrect toolchain replacement or date-based capping.
1 open issue
What changed in this PR
Updates Rust extractor toolchain selection to preserve custom-named nightly compilers, addressing #23232 while retaining the minimum nightly date requirement.
Changes:
- Recognizes nightly and development builds from
rustc --version. - Uses the compiler commit date when no nightly date is available in the toolchain name.
- Adds tests for stable, linked nightly, development, and outdated linked nightly toolchains.
| File | Description |
|---|---|
rust/extractor/src/toolchain.rs |
Adds compiler-version detection, commit-date fallback, and toolchain selection tests. |
Review effort: Balanced (adaptive)
| .unwrap_or_default() | ||
| }; | ||
| let project_toolchain = stdout(project_toolchain()); | ||
| let rustc_version = stdout(process::Command::new("rustc").arg("--version").output()); |
This branch has not been deployed
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.

Fixes #23232.
select_toolchaindecided whether the project toolchain is a nightly from its rustup name alone, so a nightly installed under another name was replaced withFIXED_RUST_TOOLCHAIN. With nightly-only flags in the Cargo config, the stable compiler then rejects every rustc call and macro expansion fails across the project (details in the issue).This PR also treats the toolchain as a nightly when
rustc --versionreports a-nightlyor-devbuild. The minimum nightly date still applies to such toolchains, using the commit date from the version string, so an old custom nightly is still replaced withnightly-{MINIMUM_NIGHTLY_DATE}.Tests: added unit tests for a stable toolchain, a linked nightly, a
-devbuild and an old linked nightly;cargo test -p codeql-rustpasses (12 tests). I also ran the patched extractor on a 370-file workspace: files extractored with errors went from 281 to 12, and the remaining 12 are build-script outputs undertarget/.