From 2fbb09a73f1f541f69b8591c3c15b44df889d1bc Mon Sep 17 00:00:00 2001 From: Aaron Wood Date: Wed, 16 Sep 2020 12:09:44 -0700 Subject: Correct project_root path for ProjectJson. It was already the folder containing the rust-project.json file, not the file itself. --- crates/project_model/src/project_json.rs | 11 ++++------- crates/rust-analyzer/src/reload.rs | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) (limited to 'crates') 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; #[derive(Clone, Debug, Eq, PartialEq)] pub struct ProjectJson { pub(crate) sysroot_src: Option, - project_root: Option, + project_root: AbsPathBuf, crates: Vec, } @@ -37,7 +37,7 @@ impl ProjectJson { pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson { ProjectJson { sysroot_src: data.sysroot_src.map(|it| base.join(it)), - project_root: base.parent().map(AbsPath::to_path_buf), + project_root: base.to_path_buf(), crates: data .crates .into_iter() @@ -91,11 +91,8 @@ impl ProjectJson { pub fn crates(&self) -> impl Iterator + '_ { self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate)) } - pub fn path(&self) -> Option<&AbsPath> { - match &self.project_root { - Some(p) => Some(p.as_path()), - None => None, - } + pub fn path(&self) -> &AbsPath { + &self.project_root } } 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 { // Enable flychecks for json projects if a custom flycheck command was supplied // in the workspace configuration. match config { - FlycheckConfig::CustomCommand { .. } => project.path(), + FlycheckConfig::CustomCommand { .. } => Some(project.path()), _ => None, } } -- cgit v1.2.3