Fix targetDir config name
This commit is contained in:
parent
83a1ad5bfe
commit
c8fdcea85c
1 changed files with 15 additions and 21 deletions
|
@ -152,6 +152,13 @@ config_data! {
|
||||||
// FIXME(@poliorcetics): move to multiple targets here too, but this will need more work
|
// FIXME(@poliorcetics): move to multiple targets here too, but this will need more work
|
||||||
// than `checkOnSave_target`
|
// than `checkOnSave_target`
|
||||||
cargo_target: Option<String> = "null",
|
cargo_target: Option<String> = "null",
|
||||||
|
/// Optional path to a rust-analyzer specific target directory.
|
||||||
|
/// This prevents rust-analyzer's `cargo check` and initial build-script and proc-macro
|
||||||
|
/// building 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.
|
||||||
|
cargo_targetDir | rust_analyzerTargetDir: Option<TargetDirectory> = "null",
|
||||||
/// Unsets the implicit `#[cfg(test)]` for the specified crates.
|
/// Unsets the implicit `#[cfg(test)]` for the specified crates.
|
||||||
cargo_unsetTest: Vec<String> = "[\"core\"]",
|
cargo_unsetTest: Vec<String> = "[\"core\"]",
|
||||||
|
|
||||||
|
@ -518,14 +525,6 @@ config_data! {
|
||||||
/// tests or binaries. For example, it may be `--release`.
|
/// tests or binaries. For example, it may be `--release`.
|
||||||
runnables_extraArgs: Vec<String> = "[]",
|
runnables_extraArgs: Vec<String> = "[]",
|
||||||
|
|
||||||
/// Optional path to a rust-analyzer specific target directory.
|
|
||||||
/// 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.
|
|
||||||
rust_analyzerTargetDir: Option<TargetDirectory> = "null",
|
|
||||||
|
|
||||||
/// Path to the Cargo.toml of the rust compiler workspace, for usage in rustc_private
|
/// Path to the Cargo.toml of the rust compiler workspace, for usage in rustc_private
|
||||||
/// projects, or "discover" to try to automatically find it if the `rustc-dev` component
|
/// projects, or "discover" to try to automatically find it if the `rustc-dev` component
|
||||||
/// is installed.
|
/// is installed.
|
||||||
|
@ -1401,14 +1400,12 @@ impl Config {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// FIXME: This should be an AbsolutePathBuf
|
|
||||||
fn target_dir_from_config(&self) -> Option<PathBuf> {
|
fn target_dir_from_config(&self) -> Option<PathBuf> {
|
||||||
self.data.rust_analyzerTargetDir.as_ref().and_then(|target_dir| match target_dir {
|
self.data.cargo_targetDir.as_ref().and_then(|target_dir| match target_dir {
|
||||||
TargetDirectory::UseSubdirectory(yes) if *yes => {
|
TargetDirectory::UseSubdirectory(true) => Some(PathBuf::from("target/rust-analyzer")),
|
||||||
Some(PathBuf::from("target/rust-analyzer"))
|
TargetDirectory::UseSubdirectory(false) => None,
|
||||||
}
|
TargetDirectory::Directory(dir) if dir.is_relative() => Some(dir.clone()),
|
||||||
TargetDirectory::UseSubdirectory(_) => None,
|
TargetDirectory::Directory(_) => None,
|
||||||
TargetDirectory::Directory(dir) => Some(dir.clone()),
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2745,7 +2742,7 @@ mod tests {
|
||||||
"rust": { "analyzerTargetDir": null }
|
"rust": { "analyzerTargetDir": null }
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(config.data.rust_analyzerTargetDir, None);
|
assert_eq!(config.data.cargo_targetDir, None);
|
||||||
assert!(
|
assert!(
|
||||||
matches!(config.flycheck(), FlycheckConfig::CargoCommand { target_dir, .. } if target_dir.is_none())
|
matches!(config.flycheck(), FlycheckConfig::CargoCommand { target_dir, .. } if target_dir.is_none())
|
||||||
);
|
);
|
||||||
|
@ -2764,10 +2761,7 @@ mod tests {
|
||||||
"rust": { "analyzerTargetDir": true }
|
"rust": { "analyzerTargetDir": true }
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(config.data.cargo_targetDir, Some(TargetDirectory::UseSubdirectory(true)));
|
||||||
config.data.rust_analyzerTargetDir,
|
|
||||||
Some(TargetDirectory::UseSubdirectory(true))
|
|
||||||
);
|
|
||||||
assert!(
|
assert!(
|
||||||
matches!(config.flycheck(), FlycheckConfig::CargoCommand { target_dir, .. } if target_dir == Some(PathBuf::from("target/rust-analyzer")))
|
matches!(config.flycheck(), FlycheckConfig::CargoCommand { target_dir, .. } if target_dir == Some(PathBuf::from("target/rust-analyzer")))
|
||||||
);
|
);
|
||||||
|
@ -2787,7 +2781,7 @@ mod tests {
|
||||||
}))
|
}))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
assert_eq!(
|
assert_eq!(
|
||||||
config.data.rust_analyzerTargetDir,
|
config.data.cargo_targetDir,
|
||||||
Some(TargetDirectory::Directory(PathBuf::from("other_folder")))
|
Some(TargetDirectory::Directory(PathBuf::from("other_folder")))
|
||||||
);
|
);
|
||||||
assert!(
|
assert!(
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue