Skip to content

Commit ab84f96

Browse files
committed
Rust: Preserve pinned nightly toolchain
Keep the exact active nightly identifier when setting RUSTUP_TOOLCHAIN so dated nightly pins are not replaced by the latest nightly. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Copilot-Session: 28cef7d1-ef57-48e7-aba0-e63e74f97d92
1 parent 8fcac38 commit ab84f96

2 files changed

Lines changed: 6 additions & 10 deletions

File tree

rust/extractor/src/config.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,7 @@ impl Config {
143143
extra_env.extend(self.cargo_extra_env.clone());
144144
extra_env.insert(
145145
"RUSTUP_TOOLCHAIN".to_owned(),
146-
Some(crate::select_toolchain().to_owned()),
146+
Some(crate::select_toolchain()),
147147
);
148148
extra_env
149149
}

rust/extractor/src/main.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -55,18 +55,14 @@ fn project_toolchain(dir: impl AsRef<Path>) -> io::Result<process::Output> {
5555
.output()
5656
}
5757

58-
fn select_toolchain() -> &'static str {
59-
let uses_nightly = project_toolchain(".")
58+
fn select_toolchain() -> String {
59+
project_toolchain(".")
6060
.ok()
6161
.filter(|output| output.status.success())
6262
.and_then(|output| String::from_utf8(output.stdout).ok())
63-
.is_some_and(|toolchain| toolchain.starts_with("nightly"));
64-
65-
if uses_nightly {
66-
"nightly"
67-
} else {
68-
DEFAULT_RUST_TOOLCHAIN
69-
}
63+
.and_then(|toolchain| toolchain.split_whitespace().next().map(str::to_owned))
64+
.filter(|toolchain| toolchain.starts_with("nightly"))
65+
.unwrap_or_else(|| DEFAULT_RUST_TOOLCHAIN.to_owned())
7066
}
7167

7268
struct Extractor<'a> {

0 commit comments

Comments
 (0)