Skip to content

Commit 9b7284d

Browse files
author
Lukas Wirth
committed
fix: Fix deadlock in recreate_crate_graph <-> file_line_index
1 parent 1f54f71 commit 9b7284d

1 file changed

Lines changed: 22 additions & 22 deletions

File tree

‎crates/rust-analyzer/src/reload.rs‎

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -522,13 +522,14 @@ impl GlobalState {
522522
}
523523

524524
fnrecreate_crate_graph(&mutself,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+
letmut 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 = &mutself.vfs.write().0;
528532
let loader = &mutself.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-
letmut 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-
letmut change = Change::new();
552-
ifself.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+
letmut change = Change::new();
552+
ifself.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)