Don't fail workspace loading if sysroot can't be found

This commit is contained in:
Lukas Wirth 2023-01-27 13:49:28 +01:00
parent 9814d79841
commit b2598f4801
4 changed files with 121 additions and 79 deletions

View file

@ -148,11 +148,11 @@ impl GlobalState {
)
}
LinkedProject::InlineJsonProject(it) => {
project_model::ProjectWorkspace::load_inline(
Ok(project_model::ProjectWorkspace::load_inline(
it.clone(),
cargo_config.target.as_deref(),
&cargo_config.extra_env,
)
))
}
})
.collect::<Vec<_>>();
@ -212,35 +212,11 @@ impl GlobalState {
let workspaces =
workspaces.iter().filter_map(|res| res.as_ref().ok().cloned()).collect::<Vec<_>>();
fn eq_ignore_build_data<'a>(
left: &'a ProjectWorkspace,
right: &'a ProjectWorkspace,
) -> bool {
let key = |p: &'a ProjectWorkspace| match p {
ProjectWorkspace::Cargo {
cargo,
sysroot,
rustc,
rustc_cfg,
cfg_overrides,
build_scripts: _,
toolchain: _,
target_layout: _,
} => Some((cargo, sysroot, rustc, rustc_cfg, cfg_overrides)),
_ => None,
};
match (key(left), key(right)) {
(Some(lk), Some(rk)) => lk == rk,
_ => left == right,
}
}
let same_workspaces = workspaces.len() == self.workspaces.len()
&& workspaces
.iter()
.zip(self.workspaces.iter())
.all(|(l, r)| eq_ignore_build_data(l, r));
.all(|(l, r)| l.eq_ignore_build_data(r));
if same_workspaces {
let (workspaces, build_scripts) = self.fetch_build_data_queue.last_op_result();
@ -270,7 +246,8 @@ impl GlobalState {
// Here, we completely changed the workspace (Cargo.toml edit), so
// we don't care about build-script results, they are stale.
self.workspaces = Arc::new(workspaces)
// FIXME: can we abort the build scripts here?
self.workspaces = Arc::new(workspaces);
}
if let FilesWatcher::Client = self.config.files().watcher {