diff options
Diffstat (limited to 'crates')
-rw-r--r-- | crates/project_model/src/project_json.rs | 11 | ||||
-rw-r--r-- | crates/rust-analyzer/src/reload.rs | 2 |
2 files changed, 5 insertions, 8 deletions
diff --git a/crates/project_model/src/project_json.rs b/crates/project_model/src/project_json.rs index 545f254aa..1ab1221cb 100644 --- a/crates/project_model/src/project_json.rs +++ b/crates/project_model/src/project_json.rs | |||
@@ -13,7 +13,7 @@ use crate::cfg_flag::CfgFlag; | |||
13 | #[derive(Clone, Debug, Eq, PartialEq)] | 13 | #[derive(Clone, Debug, Eq, PartialEq)] |
14 | pub struct ProjectJson { | 14 | pub struct ProjectJson { |
15 | pub(crate) sysroot_src: Option<AbsPathBuf>, | 15 | pub(crate) sysroot_src: Option<AbsPathBuf>, |
16 | project_root: Option<AbsPathBuf>, | 16 | project_root: AbsPathBuf, |
17 | crates: Vec<Crate>, | 17 | crates: Vec<Crate>, |
18 | } | 18 | } |
19 | 19 | ||
@@ -37,7 +37,7 @@ impl ProjectJson { | |||
37 | pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson { | 37 | pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson { |
38 | ProjectJson { | 38 | ProjectJson { |
39 | sysroot_src: data.sysroot_src.map(|it| base.join(it)), | 39 | sysroot_src: data.sysroot_src.map(|it| base.join(it)), |
40 | project_root: base.parent().map(AbsPath::to_path_buf), | 40 | project_root: base.to_path_buf(), |
41 | crates: data | 41 | crates: data |
42 | .crates | 42 | .crates |
43 | .into_iter() | 43 | .into_iter() |
@@ -91,11 +91,8 @@ impl ProjectJson { | |||
91 | pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ { | 91 | pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ { |
92 | self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate)) | 92 | self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate)) |
93 | } | 93 | } |
94 | pub fn path(&self) -> Option<&AbsPath> { | 94 | pub fn path(&self) -> &AbsPath { |
95 | match &self.project_root { | 95 | &self.project_root |
96 | Some(p) => Some(p.as_path()), | ||
97 | None => None, | ||
98 | } | ||
99 | } | 96 | } |
100 | } | 97 | } |
101 | 98 | ||
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index b819618cb..a052f36a7 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs | |||
@@ -249,7 +249,7 @@ impl GlobalState { | |||
249 | // Enable flychecks for json projects if a custom flycheck command was supplied | 249 | // Enable flychecks for json projects if a custom flycheck command was supplied |
250 | // in the workspace configuration. | 250 | // in the workspace configuration. |
251 | match config { | 251 | match config { |
252 | FlycheckConfig::CustomCommand { .. } => project.path(), | 252 | FlycheckConfig::CustomCommand { .. } => Some(project.path()), |
253 | _ => None, | 253 | _ => None, |
254 | } | 254 | } |
255 | } | 255 | } |