Skip to content

Commit fb8bc31

Browse files
authored
Merge pull request #19159 from Veykril/push-kwtzytsyktpv
fix: Set `RUSTUP_TOOLCHAIN` when loading sysroot workspace
2 parents 40e4f91 + b9f7628 commit fb8bc31

File tree

2 files changed

+6
-2
lines changed

2 files changed

+6
-2
lines changed

crates/project-model/src/cargo_workspace.rs

+3
Original file line numberDiff line numberDiff line change
@@ -277,6 +277,9 @@ impl CargoWorkspace {
277277
/// Fetches the metadata for the given `cargo_toml` manifest.
278278
/// A successful result may contain another metadata error if the initial fetching failed but
279279
/// the `--no-deps` retry succeeded.
280+
///
281+
/// The sysroot is used to set the `RUSTUP_TOOLCHAIN` env var when invoking cargo
282+
/// to ensure that the rustup proxy uses the correct toolchain.
280283
pub fn fetch_metadata(
281284
cargo_toml: &ManifestPath,
282285
current_dir: &AbsPath,

crates/project-model/src/sysroot.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -247,7 +247,7 @@ impl Sysroot {
247247
let library_manifest = ManifestPath::try_from(src_root.join("Cargo.toml")).unwrap();
248248
if fs::metadata(&library_manifest).is_ok() {
249249
if let Some(loaded) =
250-
Self::load_library_via_cargo(library_manifest, src_root, cargo_config)
250+
self.load_library_via_cargo(library_manifest, src_root, cargo_config)
251251
{
252252
return Some(loaded);
253253
}
@@ -326,6 +326,7 @@ impl Sysroot {
326326
}
327327

328328
fn load_library_via_cargo(
329+
&self,
329330
library_manifest: ManifestPath,
330331
rust_lib_src_dir: &AbsPathBuf,
331332
cargo_config: &CargoMetadataConfig,
@@ -342,7 +343,7 @@ impl Sysroot {
342343
&library_manifest,
343344
rust_lib_src_dir,
344345
&cargo_config,
345-
&Sysroot::empty(),
346+
self,
346347
// Make sure we never attempt to write to the sysroot
347348
true,
348349
&|_| (),

0 commit comments

Comments
 (0)