mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-26 16:54:01 +00:00
Address nit
This commit is contained in:
parent
1d1eea217d
commit
d6da18e99d
@ -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"
|
||||
|
@ -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
|
||||
}
|
||||
}
|
||||
|
@ -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()
|
||||
|
Loading…
Reference in New Issue
Block a user