Skip to content

Commit d1f6b4e

Browse files
committed
Auto merge of rust-lang#12023 - edwin0cheng:add-more-log, r=edwin0cheng
internal: more visibility for switch workspaces and its states
2 parents 65fbe0a + 72fcc66 commit d1f6b4e

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

crates/rust-analyzer/src/main_loop.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -236,7 +236,7 @@ impl GlobalState {
236236
self.fetch_workspaces_queue.op_completed(workspaces);
237237

238238
let old = Arc::clone(&self.workspaces);
239-
self.switch_workspaces();
239+
self.switch_workspaces("fetched workspace".to_string());
240240
let workspaces_updated = !Arc::ptr_eq(&old, &self.workspaces);
241241

242242
if self.config.run_build_scripts() && workspaces_updated {
@@ -259,7 +259,7 @@ impl GlobalState {
259259
BuildDataProgress::End(build_data_result) => {
260260
self.fetch_build_data_queue.op_completed(build_data_result);
261261

262-
self.switch_workspaces();
262+
self.switch_workspaces("fetched build data".to_string());
263263

264264
(Some(Progress::End), None)
265265
}

crates/rust-analyzer/src/reload.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,9 +166,9 @@ impl GlobalState {
166166
});
167167
}
168168

169-
pub(crate) fn switch_workspaces(&mut self) {
169+
pub(crate) fn switch_workspaces(&mut self, cause: Cause) {
170170
let _p = profile::span("GlobalState::switch_workspaces");
171-
tracing::info!("will switch workspaces");
171+
tracing::info!(%cause, "will switch workspaces");
172172

173173
if let Err(error_message) = self.fetch_workspace_error() {
174174
self.show_and_log_error(error_message, None);
@@ -224,6 +224,8 @@ impl GlobalState {
224224
if same_workspaces {
225225
let (workspaces, build_scripts) = self.fetch_build_data_queue.last_op_result();
226226
if Arc::ptr_eq(workspaces, &self.workspaces) {
227+
tracing::debug!("set build scripts to workspaces");
228+
227229
let workspaces = workspaces
228230
.iter()
229231
.cloned()
@@ -237,11 +239,14 @@ impl GlobalState {
237239
// Workspaces are the same, but we've updated build data.
238240
self.workspaces = Arc::new(workspaces);
239241
} else {
242+
tracing::info!("build scrips do not match the version of the active workspace");
240243
// Current build scripts do not match the version of the active
241244
// workspace, so there's nothing for us to update.
242245
return;
243246
}
244247
} else {
248+
tracing::debug!("abandon build scripts for workspaces");
249+
245250
// Here, we completely changed the workspace (Cargo.toml edit), so
246251
// we don't care about build-script results, they are stale.
247252
self.workspaces = Arc::new(workspaces)

0 commit comments

Comments
 (0)