Auto merge of #16645 - Veykril:deadlock, r=Veykril
fix: Fix deadlock in `recreate_crate_graph` <-> `file_line_index` Fixes https://github.com/rust-lang/rust-analyzer/issues/16614
This commit is contained in:
commit
6648f19c56
@ -522,14 +522,15 @@ impl GlobalState {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fn recreate_crate_graph(&mut self, cause: String) {
|
fn recreate_crate_graph(&mut self, cause: String) {
|
||||||
{
|
|
||||||
// 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
|
// 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
|
// deleted or created we trigger a reconstruction of the crate graph
|
||||||
let mut crate_graph_file_dependencies = FxHashSet::default();
|
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;
|
||||||
|
|
||||||
let load = |path: &AbsPath| {
|
let load = |path: &AbsPath| {
|
||||||
let _p = tracing::span!(tracing::Level::DEBUG, "switch_workspaces::load").entered();
|
let _p = tracing::span!(tracing::Level::DEBUG, "switch_workspaces::load").entered();
|
||||||
let vfs_path = vfs::VfsPath::from(path.to_path_buf());
|
let vfs_path = vfs::VfsPath::from(path.to_path_buf());
|
||||||
@ -545,9 +546,8 @@ impl GlobalState {
|
|||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
let (crate_graph, proc_macro_paths, layouts, toolchains) =
|
ws_to_crate_graph(&self.workspaces, self.config.extra_env(), load)
|
||||||
ws_to_crate_graph(&self.workspaces, self.config.extra_env(), load);
|
};
|
||||||
|
|
||||||
let mut change = Change::new();
|
let mut change = Change::new();
|
||||||
if self.config.expand_proc_macros() {
|
if self.config.expand_proc_macros() {
|
||||||
change.set_proc_macros(
|
change.set_proc_macros(
|
||||||
@ -563,7 +563,7 @@ impl GlobalState {
|
|||||||
change.set_toolchains(toolchains);
|
change.set_toolchains(toolchains);
|
||||||
self.analysis_host.apply_change(change);
|
self.analysis_host.apply_change(change);
|
||||||
self.crate_graph_file_dependencies = crate_graph_file_dependencies;
|
self.crate_graph_file_dependencies = crate_graph_file_dependencies;
|
||||||
}
|
|
||||||
self.process_changes();
|
self.process_changes();
|
||||||
self.reload_flycheck();
|
self.reload_flycheck();
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user