Skip to content

Commit 2fbb09a

Browse files
committed
Correct project_root path for ProjectJson.
It was already the folder containing the rust-project.json file, not the file itself.
1 parent 74c26a7 commit 2fbb09a

File tree

2 files changed

+5
-8
lines changed

2 files changed

+5
-8
lines changed

crates/project_model/src/project_json.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ use crate::cfg_flag::CfgFlag;
1313
#[derive(Clone, Debug, Eq, PartialEq)]
1414
pub struct ProjectJson {
1515
pub(crate) sysroot_src: Option<AbsPathBuf>,
16-
project_root: Option<AbsPathBuf>,
16+
project_root: AbsPathBuf,
1717
crates: Vec<Crate>,
1818
}
1919

@@ -37,7 +37,7 @@ impl ProjectJson {
3737
pub fn new(base: &AbsPath, data: ProjectJsonData) -> ProjectJson {
3838
ProjectJson {
3939
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(),
4141
crates: data
4242
.crates
4343
.into_iter()
@@ -91,11 +91,8 @@ impl ProjectJson {
9191
pub fn crates(&self) -> impl Iterator<Item = (CrateId, &Crate)> + '_ {
9292
self.crates.iter().enumerate().map(|(idx, krate)| (CrateId(idx as u32), krate))
9393
}
94-
pub fn path(&self) -> Option<&AbsPath> {
95-
match &self.project_root {
96-
Some(p) => Some(p.as_path()),
97-
None => None,
98-
}
94+
pub fn path(&self) -> &AbsPath {
95+
&self.project_root
9996
}
10097
}
10198

crates/rust-analyzer/src/reload.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,7 +249,7 @@ impl GlobalState {
249249
// Enable flychecks for json projects if a custom flycheck command was supplied
250250
// in the workspace configuration.
251251
match config {
252-
FlycheckConfig::CustomCommand { .. } => project.path(),
252+
FlycheckConfig::CustomCommand { .. } => Some(project.path()),
253253
_ => None,
254254
}
255255
}

0 commit comments

Comments
 (0)