Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #19159 from Veykril/push-kwtzytsyktpv
fix: Set `RUSTUP_TOOLCHAIN` when loading sysroot workspace
Lukas Wirth 2025-02-16
parent 40e4f91 · parent b9f7628 · commit fb8bc31
-rw-r--r--crates/project-model/src/cargo_workspace.rs3
-rw-r--r--crates/project-model/src/sysroot.rs5
2 files changed, 6 insertions, 2 deletions
diff --git a/crates/project-model/src/cargo_workspace.rs b/crates/project-model/src/cargo_workspace.rs
index e4a6113462..b5f4e43a11 100644
--- a/crates/project-model/src/cargo_workspace.rs
+++ b/crates/project-model/src/cargo_workspace.rs
@@ -277,6 +277,9 @@ impl CargoWorkspace {
/// Fetches the metadata for the given `cargo_toml` manifest.
/// A successful result may contain another metadata error if the initial fetching failed but
/// the `--no-deps` retry succeeded.
+ ///
+ /// The sysroot is used to set the `RUSTUP_TOOLCHAIN` env var when invoking cargo
+ /// to ensure that the rustup proxy uses the correct toolchain.
pub fn fetch_metadata(
cargo_toml: &ManifestPath,
current_dir: &AbsPath,
diff --git a/crates/project-model/src/sysroot.rs b/crates/project-model/src/sysroot.rs
index 510c18dd14..544ba43ba6 100644
--- a/crates/project-model/src/sysroot.rs
+++ b/crates/project-model/src/sysroot.rs
@@ -247,7 +247,7 @@ impl Sysroot {
let library_manifest = ManifestPath::try_from(src_root.join("Cargo.toml")).unwrap();
if fs::metadata(&library_manifest).is_ok() {
if let Some(loaded) =
- Self::load_library_via_cargo(library_manifest, src_root, cargo_config)
+ self.load_library_via_cargo(library_manifest, src_root, cargo_config)
{
return Some(loaded);
}
@@ -326,6 +326,7 @@ impl Sysroot {
}
fn load_library_via_cargo(
+ &self,
library_manifest: ManifestPath,
rust_lib_src_dir: &AbsPathBuf,
cargo_config: &CargoMetadataConfig,
@@ -342,7 +343,7 @@ impl Sysroot {
&library_manifest,
rust_lib_src_dir,
&cargo_config,
- &Sysroot::empty(),
+ self,
// Make sure we never attempt to write to the sysroot
true,
&|_| (),