diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2025-02-16 10:51:58 +0100 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2025-02-16 10:54:08 +0100 |
| commit | af804d23e204ffaec33aa7dfcd17cc31f082a559 (patch) | |
| tree | 18a8dbdf1dfff94afccd259bc785a8813d938107 /src | |
| parent | 7f8781419ca23d276ad9acbb309149cd7361a54e (diff) | |
| download | rust-af804d23e204ffaec33aa7dfcd17cc31f082a559.tar.gz rust-af804d23e204ffaec33aa7dfcd17cc31f082a559.zip | |
Set `RUSTUP_TOOLCHAIN` when loading sysroot workspace
Diffstat (limited to 'src')
| -rw-r--r-- | src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs | 3 | ||||
| -rw-r--r-- | src/tools/rust-analyzer/crates/project-model/src/sysroot.rs | 5 |
2 files changed, 6 insertions, 2 deletions
diff --git a/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs b/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs index e4a61134620..b5f4e43a115 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/cargo_workspace.rs +++ b/src/tools/rust-analyzer/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/src/tools/rust-analyzer/crates/project-model/src/sysroot.rs b/src/tools/rust-analyzer/crates/project-model/src/sysroot.rs index 510c18dd147..544ba43ba66 100644 --- a/src/tools/rust-analyzer/crates/project-model/src/sysroot.rs +++ b/src/tools/rust-analyzer/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, &|_| (), |
