Skip to content

Commit d6da18e

Browse files
committed
Address nit
1 parent 1d1eea2 commit d6da18e

File tree

3 files changed

+7
-3
lines changed

3 files changed

+7
-3
lines changed

crates/ra_lsp_server/src/world.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,7 +135,7 @@ impl WorldState {
135135
let check_watcher = {
136136
let first_workspace = workspaces.first().unwrap();
137137
let cargo_project_root = match first_workspace {
138-
ProjectWorkspace::Cargo { cargo, .. } => cargo.workspace_root.clone(),
138+
ProjectWorkspace::Cargo { cargo, .. } => cargo.workspace_root().to_path_buf(),
139139
ProjectWorkspace::Json { .. } => {
140140
log::warn!(
141141
"Cargo check watching only supported for cargo workspaces, disabling"

crates/ra_project_model/src/cargo_workspace.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ use crate::Result;
2121
pub struct CargoWorkspace {
2222
packages: Arena<Package, PackageData>,
2323
targets: Arena<Target, TargetData>,
24-
pub workspace_root: PathBuf,
24+
workspace_root: PathBuf,
2525
}
2626

2727
#[derive(Deserialize, Clone, Debug, PartialEq, Eq)]
@@ -225,4 +225,8 @@ impl CargoWorkspace {
225225
pub fn target_by_root(&self, root: &Path) -> Option<Target> {
226226
self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next()
227227
}
228+
229+
pub fn workspace_root(&self) -> &Path {
230+
&self.workspace_root
231+
}
228232
}

crates/ra_project_model/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ impl ProjectWorkspace {
333333
pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> {
334334
match self {
335335
ProjectWorkspace::Cargo { cargo, .. } => {
336-
Some(cargo.workspace_root.as_ref()).filter(|root| path.starts_with(root))
336+
Some(cargo.workspace_root()).filter(|root| path.starts_with(root))
337337
}
338338
ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots
339339
.iter()

0 commit comments

Comments
 (0)