Skip to content

Rust: Keep custom-named nightly toolchains - #23314

Open
coleleavitt wants to merge 3 commits into
github:mainfrom
coleleavitt:rust-custom-nightly-toolchain
Open

coleleavitt wants to merge 3 commits into
github:mainfrom
coleleavitt:rust-custom-nightly-toolchain

Conversation

@coleleavitt

Copy link
Copy Markdown

Fixes #23232.

The select_toolchain logic decided whether the project toolchain is a nightly from its rustup name alone, so a nightly installed under another name was replaced with FIXED_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:

  1. Runs rustup run <toolchain> rustc --version to 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.
  2. Treats the toolchain as a nightly when rustc --version reports a -nightly or -dev build, not just when the name starts with nightly.
  3. Extracts the commit date from the version string to cap old custom nightlies to MINIMUM_NIGHTLY_DATE.

Tests: added unit tests for a stable toolchain, a linked nightly, a -dev build and an old linked nightly; cargo test -p codeql-rust passes (12 tests).

Supersedes #23233 (closed due to broken git history from a shallow-clone force-push).

@coleleavitt
coleleavitt requested review from a team as code owners December 1, 2026 14:25
Copilot AI adaptive review requested due to automatic review settings December 1, 2026 14:25
@coleleavitt

Copy link
Copy Markdown
Author

@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.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔵 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 run rather than relying on rustc from PATH.
  • Recognizes -nightly and -dev builds 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)

@github-actions github-actions Bot added Rust Pull requests that update Rust code external-contribution labels Dec 1, 2026

@paldepind paldepind left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

coleleavitt and others added 3 commits December 3, 2026 15:55
`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>
@coleleavitt
coleleavitt force-pushed the rust-custom-nightly-toolchain branch from 0282751 to d9c5701 Compare December 3, 2026 20:55
@coleleavitt
coleleavitt requested a review from paldepind December 3, 2026 21:36

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

external-contribution Rust Pull requests that update Rust code

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Rust: custom-named nightly toolchains are replaced with the fixed stable toolchain

3 participants