diff options
author | Emil Lauridsen <[email protected]> | 2020-01-10 21:41:52 +0000 |
---|---|---|
committer | Emil Lauridsen <[email protected]> | 2020-01-10 21:41:52 +0000 |
commit | d6da18e99d2fb4e67e3bc7503059282b5e14bd13 (patch) | |
tree | 712cdb37b25f553c5739f319a849414de480cff4 /crates | |
parent | 1d1eea217d5b674e6cad77704f912a3a76505d70 (diff) |
Address nit
Diffstat (limited to 'crates')
-rw-r--r-- | crates/ra_lsp_server/src/world.rs | 2 | ||||
-rw-r--r-- | crates/ra_project_model/src/cargo_workspace.rs | 6 | ||||
-rw-r--r-- | crates/ra_project_model/src/lib.rs | 2 |
3 files changed, 7 insertions, 3 deletions
diff --git a/crates/ra_lsp_server/src/world.rs b/crates/ra_lsp_server/src/world.rs index 36b5242d1..cea18937f 100644 --- a/crates/ra_lsp_server/src/world.rs +++ b/crates/ra_lsp_server/src/world.rs | |||
@@ -135,7 +135,7 @@ impl WorldState { | |||
135 | let check_watcher = { | 135 | let check_watcher = { |
136 | let first_workspace = workspaces.first().unwrap(); | 136 | let first_workspace = workspaces.first().unwrap(); |
137 | let cargo_project_root = match first_workspace { | 137 | 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(), |
139 | ProjectWorkspace::Json { .. } => { | 139 | ProjectWorkspace::Json { .. } => { |
140 | log::warn!( | 140 | log::warn!( |
141 | "Cargo check watching only supported for cargo workspaces, disabling" | 141 | "Cargo check watching only supported for cargo workspaces, disabling" |
diff --git a/crates/ra_project_model/src/cargo_workspace.rs b/crates/ra_project_model/src/cargo_workspace.rs index 18c2f11b7..1832c101f 100644 --- a/crates/ra_project_model/src/cargo_workspace.rs +++ b/crates/ra_project_model/src/cargo_workspace.rs | |||
@@ -21,7 +21,7 @@ use crate::Result; | |||
21 | pub struct CargoWorkspace { | 21 | pub struct CargoWorkspace { |
22 | packages: Arena<Package, PackageData>, | 22 | packages: Arena<Package, PackageData>, |
23 | targets: Arena<Target, TargetData>, | 23 | targets: Arena<Target, TargetData>, |
24 | pub workspace_root: PathBuf, | 24 | workspace_root: PathBuf, |
25 | } | 25 | } |
26 | 26 | ||
27 | #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] | 27 | #[derive(Deserialize, Clone, Debug, PartialEq, Eq)] |
@@ -225,4 +225,8 @@ impl CargoWorkspace { | |||
225 | pub fn target_by_root(&self, root: &Path) -> Option<Target> { | 225 | pub fn target_by_root(&self, root: &Path) -> Option<Target> { |
226 | self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next() | 226 | self.packages().filter_map(|pkg| pkg.targets(self).find(|it| it.root(self) == root)).next() |
227 | } | 227 | } |
228 | |||
229 | pub fn workspace_root(&self) -> &Path { | ||
230 | &self.workspace_root | ||
231 | } | ||
228 | } | 232 | } |
diff --git a/crates/ra_project_model/src/lib.rs b/crates/ra_project_model/src/lib.rs index b7f6a9b57..6a104e6f2 100644 --- a/crates/ra_project_model/src/lib.rs +++ b/crates/ra_project_model/src/lib.rs | |||
@@ -333,7 +333,7 @@ impl ProjectWorkspace { | |||
333 | pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> { | 333 | pub fn workspace_root_for(&self, path: &Path) -> Option<&Path> { |
334 | match self { | 334 | match self { |
335 | ProjectWorkspace::Cargo { cargo, .. } => { | 335 | 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)) |
337 | } | 337 | } |
338 | ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots | 338 | ProjectWorkspace::Json { project: JsonProject { roots, .. } } => roots |
339 | .iter() | 339 | .iter() |