Unnamed repository; edit this file 'description' to name the repository.
fix: Fix deadlock in recreate_crate_graph <-> file_line_index
Lukas Wirth 2024-02-23
parent 1f54f71 · commit 9b7284d
-rw-r--r--crates/rust-analyzer/src/reload.rs44
1 files changed, 22 insertions, 22 deletions
diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs
index 00494ca5ba..f6bc032c01 100644
--- a/crates/rust-analyzer/src/reload.rs
+++ b/crates/rust-analyzer/src/reload.rs
@@ -522,13 +522,14 @@ impl GlobalState {
}
fn recreate_crate_graph(&mut self, cause: String) {
- {
+ // crate graph construction relies on these paths, record them so when one of them gets
+ // deleted or created we trigger a reconstruction of the crate graph
+ let mut crate_graph_file_dependencies = FxHashSet::default();
+
+ let (crate_graph, proc_macro_paths, layouts, toolchains) = {
// Create crate graph from all the workspaces
let vfs = &mut self.vfs.write().0;
let loader = &mut self.loader;
- // crate graph construction relies on these paths, record them so when one of them gets
- // deleted or created we trigger a reconstruction of the crate graph
- let mut crate_graph_file_dependencies = FxHashSet::default();
let load = |path: &AbsPath| {
let _p = tracing::span!(tracing::Level::DEBUG, "switch_workspaces::load").entered();
@@ -545,25 +546,24 @@ impl GlobalState {
}
};
- let (crate_graph, proc_macro_paths, layouts, toolchains) =
- ws_to_crate_graph(&self.workspaces, self.config.extra_env(), load);
-
- let mut change = Change::new();
- if self.config.expand_proc_macros() {
- change.set_proc_macros(
- crate_graph
- .iter()
- .map(|id| (id, Err("Proc-macros have not been built yet".to_owned())))
- .collect(),
- );
- self.fetch_proc_macros_queue.request_op(cause, proc_macro_paths);
- }
- change.set_crate_graph(crate_graph);
- change.set_target_data_layouts(layouts);
- change.set_toolchains(toolchains);
- self.analysis_host.apply_change(change);
- self.crate_graph_file_dependencies = crate_graph_file_dependencies;
+ ws_to_crate_graph(&self.workspaces, self.config.extra_env(), load)
+ };
+ let mut change = Change::new();
+ if self.config.expand_proc_macros() {
+ change.set_proc_macros(
+ crate_graph
+ .iter()
+ .map(|id| (id, Err("Proc-macros have not been built yet".to_owned())))
+ .collect(),
+ );
+ self.fetch_proc_macros_queue.request_op(cause, proc_macro_paths);
}
+ change.set_crate_graph(crate_graph);
+ change.set_target_data_layouts(layouts);
+ change.set_toolchains(toolchains);
+ self.analysis_host.apply_change(change);
+ self.crate_graph_file_dependencies = crate_graph_file_dependencies;
+
self.process_changes();
self.reload_flycheck();
}