Unnamed repository; edit this file 'description' to name the repository.
Merge pull request #18827 from Veykril/push-zqsplmtwsxxk
minor: Honor `CARGO_TARGET_DIR` for cargo target dir config
Lukas Wirth 2025-01-03
parent ce6053c · parent 7d20367 · commit 3d63003
-rw-r--r--crates/rust-analyzer/src/config.rs5
1 files changed, 4 insertions, 1 deletions
diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs
index fd2219c502..f054bde903 100644
--- a/crates/rust-analyzer/src/config.rs
+++ b/crates/rust-analyzer/src/config.rs
@@ -2126,7 +2126,10 @@ impl Config {
fn target_dir_from_config(&self, source_root: Option<SourceRootId>) -> Option<Utf8PathBuf> {
self.cargo_targetDir(source_root).as_ref().and_then(|target_dir| match target_dir {
TargetDirectory::UseSubdirectory(true) => {
- Some(Utf8PathBuf::from("target/rust-analyzer"))
+ let env_var = env::var("CARGO_TARGET_DIR").ok();
+ let mut path = Utf8PathBuf::from(env_var.as_deref().unwrap_or("target"));
+ path.push("rust-analyzer");
+ Some(path)
}
TargetDirectory::UseSubdirectory(false) => None,
TargetDirectory::Directory(dir) => Some(dir.clone()),