Correct project_root path for ProjectJson.

It was already the folder containing the rust-project.json file, not the file itself.
This commit is contained in:
Aaron Wood 2020-09-16 12:09:44 -07:00
parent 74c26a785a
commit 2fbb09a73f
2 changed files with 5 additions and 8 deletions

View file

@ -13,7 +13,7 @@ use crate::cfg_flag::CfgFlag;
#[derive(Clone, Debug, Eq, PartialEq)]
pub struct ProjectJson {
pub(crate) sysroot_src: Option<AbsPathBuf>,
project_root: Option<AbsPathBuf>,
project_root: AbsPathBuf,
crates: Vec<Crate>,
}
@ -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<Item = (CrateId, &Crate)> + '_ {
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
}
}

View file

@ -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,
}
}