diff --git a/crates/proc-macro-api/src/lib.rs b/crates/proc-macro-api/src/lib.rs index 7b2e209b8e03..4b5e25e48801 100644 --- a/crates/proc-macro-api/src/lib.rs +++ b/crates/proc-macro-api/src/lib.rs @@ -87,6 +87,7 @@ pub struct ProcMacroClient { /// That means that concurrent salsa requests may block each other when expanding proc macros, /// which is unfortunate, but simple and good enough for the time being. pool: Arc, + /// The path to the proc-macro server binary. path: AbsPathBuf, } diff --git a/crates/rust-analyzer/src/global_state.rs b/crates/rust-analyzer/src/global_state.rs index 76a79ae08d89..c0d87104fbe1 100644 --- a/crates/rust-analyzer/src/global_state.rs +++ b/crates/rust-analyzer/src/global_state.rs @@ -105,8 +105,13 @@ pub(crate) struct GlobalState { pub(crate) shutdown_requested: bool, pub(crate) last_reported_status: lsp_ext::ServerStatusParams, - // proc macros + /// Clients of the proc-macro server. + /// + /// One client per workspace, in the same order as `self.workspaces`. We don't store + /// the client in `self.workspaces` so that we can reload workspaces without + /// restarting the proc-macro server. pub(crate) proc_macro_clients: Arc<[Option>]>, + pub(crate) build_deps_changed: bool, // Flycheck diff --git a/crates/rust-analyzer/src/reload.rs b/crates/rust-analyzer/src/reload.rs index 173409b32585..86c954b089e4 100644 --- a/crates/rust-analyzer/src/reload.rs +++ b/crates/rust-analyzer/src/reload.rs @@ -659,7 +659,7 @@ impl GlobalState { Config::user_config_dir_path().as_deref(), ); - if (self.proc_macro_clients.is_empty() || !same_workspaces) + if (self.proc_macro_clients.len() < self.workspaces.len() || !same_workspaces) && self.config.expand_proc_macros() { info!("Spawning proc-macro servers");