Skip to content

Commit c8fdcea

Browse files
committed
Fix targetDir config name
1 parent 83a1ad5 commit c8fdcea

File tree

1 file changed

+15
-21
lines changed

1 file changed

+15
-21
lines changed

crates/rust-analyzer/src/config.rs

Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,13 @@ config_data! {
152152
// FIXME(@poliorcetics): move to multiple targets here too, but this will need more work
153153
// than `checkOnSave_target`
154154
cargo_target: Option<String> = "null",
155+
/// Optional path to a rust-analyzer specific target directory.
156+
/// This prevents rust-analyzer's `cargo check` and initial build-script and proc-macro
157+
/// building from locking the `Cargo.lock` at the expense of duplicating build artifacts.
158+
///
159+
/// Set to `true` to use a subdirectory of the existing target directory or
160+
/// set to a path relative to the workspace to use that path.
161+
cargo_targetDir | rust_analyzerTargetDir: Option<TargetDirectory> = "null",
155162
/// Unsets the implicit `#[cfg(test)]` for the specified crates.
156163
cargo_unsetTest: Vec<String> = "[\"core\"]",
157164

@@ -518,14 +525,6 @@ config_data! {
518525
/// tests or binaries. For example, it may be `--release`.
519526
runnables_extraArgs: Vec<String> = "[]",
520527

521-
/// Optional path to a rust-analyzer specific target directory.
522-
/// This prevents rust-analyzer's `cargo check` from locking the `Cargo.lock`
523-
/// at the expense of duplicating build artifacts.
524-
///
525-
/// Set to `true` to use a subdirectory of the existing target directory or
526-
/// set to a path relative to the workspace to use that path.
527-
rust_analyzerTargetDir: Option<TargetDirectory> = "null",
528-
529528
/// Path to the Cargo.toml of the rust compiler workspace, for usage in rustc_private
530529
/// projects, or "discover" to try to automatically find it if the `rustc-dev` component
531530
/// is installed.
@@ -1401,14 +1400,12 @@ impl Config {
14011400
}
14021401
}
14031402

1404-
// FIXME: This should be an AbsolutePathBuf
14051403
fn target_dir_from_config(&self) -> Option<PathBuf> {
1406-
self.data.rust_analyzerTargetDir.as_ref().and_then(|target_dir| match target_dir {
1407-
TargetDirectory::UseSubdirectory(yes) if *yes => {
1408-
Some(PathBuf::from("target/rust-analyzer"))
1409-
}
1410-
TargetDirectory::UseSubdirectory(_) => None,
1411-
TargetDirectory::Directory(dir) => Some(dir.clone()),
1404+
self.data.cargo_targetDir.as_ref().and_then(|target_dir| match target_dir {
1405+
TargetDirectory::UseSubdirectory(true) => Some(PathBuf::from("target/rust-analyzer")),
1406+
TargetDirectory::UseSubdirectory(false) => None,
1407+
TargetDirectory::Directory(dir) if dir.is_relative() => Some(dir.clone()),
1408+
TargetDirectory::Directory(_) => None,
14121409
})
14131410
}
14141411

@@ -2745,7 +2742,7 @@ mod tests {
27452742
"rust": { "analyzerTargetDir": null }
27462743
}))
27472744
.unwrap();
2748-
assert_eq!(config.data.rust_analyzerTargetDir, None);
2745+
assert_eq!(config.data.cargo_targetDir, None);
27492746
assert!(
27502747
matches!(config.flycheck(), FlycheckConfig::CargoCommand { target_dir, .. } if target_dir.is_none())
27512748
);
@@ -2764,10 +2761,7 @@ mod tests {
27642761
"rust": { "analyzerTargetDir": true }
27652762
}))
27662763
.unwrap();
2767-
assert_eq!(
2768-
config.data.rust_analyzerTargetDir,
2769-
Some(TargetDirectory::UseSubdirectory(true))
2770-
);
2764+
assert_eq!(config.data.cargo_targetDir, Some(TargetDirectory::UseSubdirectory(true)));
27712765
assert!(
27722766
matches!(config.flycheck(), FlycheckConfig::CargoCommand { target_dir, .. } if target_dir == Some(PathBuf::from("target/rust-analyzer")))
27732767
);
@@ -2787,7 +2781,7 @@ mod tests {
27872781
}))
27882782
.unwrap();
27892783
assert_eq!(
2790-
config.data.rust_analyzerTargetDir,
2784+
config.data.cargo_targetDir,
27912785
Some(TargetDirectory::Directory(PathBuf::from("other_folder")))
27922786
);
27932787
assert!(

0 commit comments

Comments
 (0)