Skip to content

Commit 60c4f07

Browse files
committed
Auto merge of rust-lang#12007 - edwin0cheng:restart-proc-macro-reload, r=jonas-schievink
Restart proc-macro client when server reload Fix rust-lang#10719
2 parents 1d2bd0e + 8f616a6 commit 60c4f07

File tree

2 files changed

+14
-6
lines changed

2 files changed

+14
-6
lines changed

crates/rust-analyzer/src/handlers.rs

+7
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,13 @@ use crate::{
4343
to_proto, LspError, Result,
4444
};
4545

46+
pub(crate) fn handle_workspace_reload(state: &mut GlobalState, _: ()) -> Result<()> {
47+
state.proc_macro_client = None;
48+
state.fetch_workspaces_queue.request_op("reload workspace request".to_string());
49+
state.fetch_build_data_queue.request_op("reload workspace request".to_string());
50+
Ok(())
51+
}
52+
4653
pub(crate) fn handle_analyzer_status(
4754
snap: GlobalStateSnapshot,
4855
params: lsp_ext::AnalyzerStatusParams,

crates/rust-analyzer/src/main_loop.rs

+7-6
Original file line numberDiff line numberDiff line change
@@ -499,9 +499,13 @@ impl GlobalState {
499499
self.fetch_workspaces(cause);
500500
}
501501
}
502-
if let Some(cause) = self.fetch_build_data_queue.should_start_op() {
503-
self.fetch_build_data(cause);
502+
503+
if !self.fetch_workspaces_queue.op_in_progress() {
504+
if let Some(cause) = self.fetch_build_data_queue.should_start_op() {
505+
self.fetch_build_data(cause);
506+
}
504507
}
508+
505509
if let Some(cause) = self.prime_caches_queue.should_start_op() {
506510
tracing::debug!(%cause, "will prime caches");
507511
let num_worker_threads = self.config.prime_caches_num_threads();
@@ -571,14 +575,11 @@ impl GlobalState {
571575
}
572576

573577
RequestDispatcher { req: Some(req), global_state: self }
574-
.on_sync_mut::<lsp_ext::ReloadWorkspace>(|s, ()| {
575-
s.fetch_workspaces_queue.request_op("reload workspace request".to_string());
576-
Ok(())
577-
})?
578578
.on_sync_mut::<lsp_types::request::Shutdown>(|s, ()| {
579579
s.shutdown_requested = true;
580580
Ok(())
581581
})?
582+
.on_sync_mut::<lsp_ext::ReloadWorkspace>(handlers::handle_workspace_reload)?
582583
.on_sync_mut::<lsp_ext::MemoryUsage>(handlers::handle_memory_usage)?
583584
.on_sync_mut::<lsp_ext::ShuffleCrateGraph>(handlers::handle_shuffle_crate_graph)?
584585
.on_sync::<lsp_ext::JoinLines>(handlers::handle_join_lines)?

0 commit comments

Comments
 (0)