Skip to content

Commit 31b45b0

Browse files
authored
Merge pull request rust-lang#18827 from Veykril/push-zqsplmtwsxxk
minor: Honor `CARGO_TARGET_DIR` for cargo target dir config
2 parents 2e7d94b + 40b37ee commit 31b45b0

File tree

1 file changed

+4
-1
lines changed
  • src/tools/rust-analyzer/crates/rust-analyzer/src

1 file changed

+4
-1
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2126,7 +2126,10 @@ impl Config {
21262126
fn target_dir_from_config(&self, source_root: Option<SourceRootId>) -> Option<Utf8PathBuf> {
21272127
self.cargo_targetDir(source_root).as_ref().and_then(|target_dir| match target_dir {
21282128
TargetDirectory::UseSubdirectory(true) => {
2129-
Some(Utf8PathBuf::from("target/rust-analyzer"))
2129+
let env_var = env::var("CARGO_TARGET_DIR").ok();
2130+
let mut path = Utf8PathBuf::from(env_var.as_deref().unwrap_or("target"));
2131+
path.push("rust-analyzer");
2132+
Some(path)
21302133
}
21312134
TargetDirectory::UseSubdirectory(false) => None,
21322135
TargetDirectory::Directory(dir) => Some(dir.clone()),

0 commit comments

Comments
 (0)