Skip to content

Commit 6648f19

Browse files
committed
Auto merge of #16645 - Veykril:deadlock, r=Veykril
fix: Fix deadlock in `recreate_crate_graph` <-> `file_line_index` Fixes #16614
2 parents 1f54f71 + 9b7284d commit 6648f19

File tree

1 file changed

+22
-22
lines changed

1 file changed

+22
-22
lines changed

crates/rust-analyzer/src/reload.rs

+22-22
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,14 @@ impl GlobalState {
522522
}
523523

524524
fn recreate_crate_graph(&mut self, cause: String) {
525-
{
525+
// crate graph construction relies on these paths, record them so when one of them gets
526+
// deleted or created we trigger a reconstruction of the crate graph
527+
let mut crate_graph_file_dependencies = FxHashSet::default();
528+
529+
let (crate_graph, proc_macro_paths, layouts, toolchains) = {
526530
// Create crate graph from all the workspaces
527531
let vfs = &mut self.vfs.write().0;
528532
let loader = &mut self.loader;
529-
// crate graph construction relies on these paths, record them so when one of them gets
530-
// deleted or created we trigger a reconstruction of the crate graph
531-
let mut crate_graph_file_dependencies = FxHashSet::default();
532533

533534
let load = |path: &AbsPath| {
534535
let _p = tracing::span!(tracing::Level::DEBUG, "switch_workspaces::load").entered();
@@ -545,25 +546,24 @@ impl GlobalState {
545546
}
546547
};
547548

548-
let (crate_graph, proc_macro_paths, layouts, toolchains) =
549-
ws_to_crate_graph(&self.workspaces, self.config.extra_env(), load);
550-
551-
let mut change = Change::new();
552-
if self.config.expand_proc_macros() {
553-
change.set_proc_macros(
554-
crate_graph
555-
.iter()
556-
.map(|id| (id, Err("Proc-macros have not been built yet".to_owned())))
557-
.collect(),
558-
);
559-
self.fetch_proc_macros_queue.request_op(cause, proc_macro_paths);
560-
}
561-
change.set_crate_graph(crate_graph);
562-
change.set_target_data_layouts(layouts);
563-
change.set_toolchains(toolchains);
564-
self.analysis_host.apply_change(change);
565-
self.crate_graph_file_dependencies = crate_graph_file_dependencies;
549+
ws_to_crate_graph(&self.workspaces, self.config.extra_env(), load)
550+
};
551+
let mut change = Change::new();
552+
if self.config.expand_proc_macros() {
553+
change.set_proc_macros(
554+
crate_graph
555+
.iter()
556+
.map(|id| (id, Err("Proc-macros have not been built yet".to_owned())))
557+
.collect(),
558+
);
559+
self.fetch_proc_macros_queue.request_op(cause, proc_macro_paths);
566560
}
561+
change.set_crate_graph(crate_graph);
562+
change.set_target_data_layouts(layouts);
563+
change.set_toolchains(toolchains);
564+
self.analysis_host.apply_change(change);
565+
self.crate_graph_file_dependencies = crate_graph_file_dependencies;
566+
567567
self.process_changes();
568568
self.reload_flycheck();
569569
}

0 commit comments

Comments
 (0)