Address nit

This commit is contained in:
Emil Lauridsen 2020-01-10 22:41:52 +01:00
parent 1d1eea217d
commit d6da18e99d
3 changed files with 7 additions and 3 deletions

View file

@ -135,7 +135,7 @@ impl WorldState {
let check_watcher = {
let first_workspace = workspaces.first().unwrap();
let cargo_project_root = match first_workspace {
ProjectWorkspace::Cargo { cargo, .. } => cargo.workspace_root.clone(),
ProjectWorkspace::Cargo { cargo, .. } => cargo.workspace_root().to_path_buf(),
ProjectWorkspace::Json { .. } => {
log::warn!(
"Cargo check watching only supported for cargo workspaces, disabling"

View file

@ -21,7 +21,7 @@ use crate::Result;
pub struct CargoWorkspace {
packages: Arena<Package, PackageData>,
targets: Arena<Target, TargetData>,
pub workspace_root: PathBuf,
workspace_root: PathBuf,
}
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
@ -225,4 +225,8 @@ impl CargoWorkspace {
pub fn target_by_root(&self, root: &Path) -> Option<Target> {
self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next()
}
pub fn workspace_root(&self) -> &Path {
&self.workspace_root
}
}

View file

@ -333,7 +333,7 @@ impl ProjectWorkspace {
pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> {
match self {
ProjectWorkspace::Cargo { cargo, .. } => {
Some(cargo.workspace_root.as_ref()).filter(|root| path.starts_with(root))
Some(cargo.workspace_root()).filter(|root| path.starts_with(root))
}
ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots
.iter()