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 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) (limited to 'crates/project_model') 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 } } -- cgit v1.2.3