mirror of
https://github.com/rust-lang/rust-analyzer.git
synced 2025-10-01 22:31:43 +00:00
Don't fail workspace loading if sysroot can't be found
This commit is contained in:
parent
9814d79841
commit
b2598f4801
4 changed files with 121 additions and 79 deletions
|
@ -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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue