Skip to content

Commit

Permalink
minor: Honor CARGO_TARGET_DIR for cargo target dir config
Browse files Browse the repository at this point in the history
  • Loading branch information
Veykril committed Jan 3, 2025
1 parent 70ba3b5 commit 40b37ee
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion src/tools/rust-analyzer/crates/rust-analyzer/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()),
Expand Down

0 comments on commit 40b37ee

Please sign in to comment.