Repository navigation
Rust: Keep custom-named nightly toolchains - #23314
coleleavitt wants to merge 3 commits into
Conversation
|
@paldepind Reopened with fixed git history (the shallow-clone force-push broke it). Same change, now with Copilot's suggestion baked in from the start and a clean 1-commit diff. |
There was a problem hiding this comment.
🔵 Needs a closer look
Preserving linked nightly/dev toolchains and custom compiler builds affects Cargo, sysroot discovery, and procedural macros, requiring integration review of rust-analyzer compatibility beyond local selection tests.
No open issues 🎉
What changed in this PR
Updates Rust extractor toolchain selection to preserve custom-named nightly compilers, addressing #23232 while retaining the minimum supported nightly date.
Changes:
- Queries the active toolchain through
rustup runrather than relying onrustcfrom PATH. - Recognizes
-nightlyand-devbuilds and uses their commit dates to replace outdated custom nightlies. - Adds unit tests for stable, custom nightly, development, and outdated custom toolchains.
| File | Description |
|---|---|
rust/extractor/src/toolchain.rs |
Adds compiler-version detection, date fallback, and toolchain-selection tests. |
Review effort: Balanced (adaptive)
paldepind
left a comment
There was a problem hiding this comment.
Thanks.
This new version of the PR has some additional changes that where not in the original. For instance, there is now a stdout function and the comment that should be attached to select_toolchain is now mistakenly attached to stdout.
I'd prefer and propose that we change the PR to the original change + the Copilot suggestion + the formatting fixes that cargo fmt picked up.
`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.
Run `rustup run <toolchain> rustc --version` instead of bare `rustc --version` so the version probe hits the same toolchain rustup selected, not an unrelated rustc earlier on PATH. Co-authored-by: Copilot <copilot-pull-request-reviewer@github.com>
0282751 to
d9c5701
Compare
Fixes #23232.
The
select_toolchainlogic decided 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:
rustup run <toolchain> rustc --versionto get the version from the actual active toolchain (not a stray rustc on PATH) — addresses Copilot's review comment from Rust: Keep custom-named nightly toolchains #23233.rustc --versionreports a-nightlyor-devbuild, not just when the name starts 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).Supersedes #23233 (closed due to broken git history from a shallow-clone force-push).