diff --git a/crates/rust-analyzer/src/config.rs b/crates/rust-analyzer/src/config.rs index 39a98bcd29..c8df4255d9 100644 --- a/crates/rust-analyzer/src/config.rs +++ b/crates/rust-analyzer/src/config.rs @@ -481,7 +481,8 @@ config_data! { runnables_extraArgs: Vec = "[]", /// Optional path to a rust-analyzer specific target directory. - /// This is useful to prevent rust-analyzer's `cargo check` from blocking builds. + /// This prevents rust-analyzer's `cargo check` from locking the `Cargo.lock` + /// at the expense of duplicating build artifacts. /// /// Set to `true` to use a subdirectory of the existing target directory or /// set to a path relative to the workspace to use that path. @@ -1349,17 +1350,13 @@ impl Config { } fn target_dir_from_config(&self) -> Option { - self.data - .rust_analyzerTargetDir - .as_ref() - .map(|target_dir| match target_dir { - TargetDirectory::UseSubdirectory(yes) if *yes => { - Some(PathBuf::from("target/rust-analyzer")) - } - TargetDirectory::UseSubdirectory(_) => None, - TargetDirectory::Directory(dir) => Some(dir.clone()), - }) - .flatten() + self.data.rust_analyzerTargetDir.as_ref().and_then(|target_dir| match target_dir { + TargetDirectory::UseSubdirectory(yes) if *yes => { + Some(PathBuf::from("target/rust-analyzer")) + } + TargetDirectory::UseSubdirectory(_) => None, + TargetDirectory::Directory(dir) => Some(dir.clone()), + }) } pub fn check_on_save(&self) -> bool { diff --git a/docs/user/generated_config.adoc b/docs/user/generated_config.adoc index 4440caaed8..7c76ae81be 100644 --- a/docs/user/generated_config.adoc +++ b/docs/user/generated_config.adoc @@ -761,7 +761,8 @@ tests or binaries. For example, it may be `--release`. + -- Optional path to a rust-analyzer specific target directory. -This is useful to prevent rust-analyzer's `cargo check` from blocking builds. +This prevents rust-analyzer's `cargo check` from locking the `Cargo.lock` +at the expense of duplicating build artifacts. Set to `true` to use a subdirectory of the existing target directory or set to a path relative to the workspace to use that path. diff --git a/editors/code/package.json b/editors/code/package.json index a18acb9830..fc6597a0d4 100644 --- a/editors/code/package.json +++ b/editors/code/package.json @@ -1489,7 +1489,7 @@ } }, "rust-analyzer.rust.analyzerTargetDir": { - "markdownDescription": "Optional path to a rust-analyzer specific target directory.\nThis is useful to prevent rust-analyzer's `cargo check` from blocking builds.\n\nSet to `true` to use a subdirectory of the existing target directory or\nset to a path relative to the workspace to use that path.", + "markdownDescription": "Optional path to a rust-analyzer specific target directory.\nThis prevents rust-analyzer's `cargo check` from locking the `Cargo.lock`\nat the expense of duplicating build artifacts.\n\nSet to `true` to use a subdirectory of the existing target directory or\nset to a path relative to the workspace to use that path.", "default": null, "anyOf": [ {