Skip to content

Commit a39d207

Browse files
committed
Addressed PR style comments
1 parent 9771e1e commit a39d207

File tree

3 files changed

+12
-14
lines changed

3 files changed

+12
-14
lines changed

crates/rust-analyzer/src/config.rs

+9-12
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,8 @@ config_data! {
481481
runnables_extraArgs: Vec<String> = "[]",
482482

483483
/// Optional path to a rust-analyzer specific target directory.
484-
/// This is useful to prevent rust-analyzer's `cargo check` from blocking builds.
484+
/// This prevents rust-analyzer's `cargo check` from locking the `Cargo.lock`
485+
/// at the expense of duplicating build artifacts.
485486
///
486487
/// Set to `true` to use a subdirectory of the existing target directory or
487488
/// set to a path relative to the workspace to use that path.
@@ -1349,17 +1350,13 @@ impl Config {
13491350
}
13501351

13511352
fn target_dir_from_config(&self) -> Option<PathBuf> {
1352-
self.data
1353-
.rust_analyzerTargetDir
1354-
.as_ref()
1355-
.map(|target_dir| match target_dir {
1356-
TargetDirectory::UseSubdirectory(yes) if *yes => {
1357-
Some(PathBuf::from("target/rust-analyzer"))
1358-
}
1359-
TargetDirectory::UseSubdirectory(_) => None,
1360-
TargetDirectory::Directory(dir) => Some(dir.clone()),
1361-
})
1362-
.flatten()
1353+
self.data.rust_analyzerTargetDir.as_ref().and_then(|target_dir| match target_dir {
1354+
TargetDirectory::UseSubdirectory(yes) if *yes => {
1355+
Some(PathBuf::from("target/rust-analyzer"))
1356+
}
1357+
TargetDirectory::UseSubdirectory(_) => None,
1358+
TargetDirectory::Directory(dir) => Some(dir.clone()),
1359+
})
13631360
}
13641361

13651362
pub fn check_on_save(&self) -> bool {

docs/user/generated_config.adoc

+2-1
Original file line numberDiff line numberDiff line change
@@ -761,7 +761,8 @@ tests or binaries. For example, it may be `--release`.
761761
+
762762
--
763763
Optional path to a rust-analyzer specific target directory.
764-
This is useful to prevent rust-analyzer's `cargo check` from blocking builds.
764+
This prevents rust-analyzer's `cargo check` from locking the `Cargo.lock`
765+
at the expense of duplicating build artifacts.
765766

766767
Set to `true` to use a subdirectory of the existing target directory or
767768
set to a path relative to the workspace to use that path.

editors/code/package.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1489,7 +1489,7 @@
14891489
}
14901490
},
14911491
"rust-analyzer.rust.analyzerTargetDir": {
1492-
"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.",
1492+
"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.",
14931493
"default": null,
14941494
"anyOf": [
14951495
{

0 commit comments

Comments
 (0)