Skip to content

Rust: Keep custom-named nightly toolchains - #23233

Open
coleleavitt wants to merge 1 commit into
github:mainfrom
coleleavitt:rust-custom-nightly-toolchain
Open

coleleavitt wants to merge 1 commit into
github:mainfrom
coleleavitt:rust-custom-nightly-toolchain

Conversation

@coleleavitt

Copy link
Copy Markdown

Fixes #23232.

select_toolchain 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 also treats the toolchain as a nightly when rustc --version reports a -nightly or -dev build. 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 with nightly-{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). 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 under target/.

`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.
@coleleavitt
coleleavitt requested review from a team as code owners November 24, 2026 16:26
Copilot AI adaptive review requested due to automatic review settings November 24, 2026 16:26
@github-actions github-actions Bot added Rust Pull requests that update Rust code external-contribution labels Nov 24, 2026

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.

🟡 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

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

2 participants