Skip to content

Commit f3998f7

Browse files
authored
Merge pull request #19080 from Veykril/push-wlqsvqsksupr
More rustfmt hang investigations
2 parents 88b9018 + a830096 commit f3998f7

File tree

4 files changed

+18
-14
lines changed

4 files changed

+18
-14
lines changed

Diff for: crates/rust-analyzer/src/global_state.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -396,6 +396,7 @@ impl GlobalState {
396396
|| !self.config.same_source_root_parent_map(&self.local_roots_parent_map)
397397
{
398398
let config_change = {
399+
let _p = span!(Level::INFO, "GlobalState::process_changes/config_change").entered();
399400
let user_config_path = (|| {
400401
let mut p = Config::user_config_dir_path()?;
401402
p.push("rust-analyzer.toml");
@@ -569,12 +570,12 @@ impl GlobalState {
569570
if let Some((method, start)) = self.req_queue.incoming.complete(&response.id) {
570571
if let Some(err) = &response.error {
571572
if err.message.starts_with("server panicked") {
572-
self.poke_rust_analyzer_developer(format!("{}, check the log", err.message))
573+
self.poke_rust_analyzer_developer(format!("{}, check the log", err.message));
573574
}
574575
}
575576

576577
let duration = start.elapsed();
577-
tracing::debug!("handled {} - ({}) in {:0.2?}", method, response.id, duration);
578+
tracing::debug!(name: "message response", method, %response.id, duration = format_args!("{:0.2?}", duration));
578579
self.send(response.into());
579580
}
580581
}

Diff for: crates/rust-analyzer/src/handlers/notification.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,8 @@ pub(crate) fn handle_did_open_text_document(
7474
tracing::error!("duplicate DidOpenTextDocument: {}", path);
7575
}
7676

77-
state.vfs.write().0.set_file_contents(path, Some(params.text_document.text.into_bytes()));
77+
let contents = params.text_document.text.into_bytes();
78+
state.vfs.write().0.set_file_contents(path, Some(contents));
7879
if state.config.discover_workspace_config().is_some() {
7980
tracing::debug!("queuing task");
8081
let _ = state

Diff for: crates/rust-analyzer/src/handlers/request.rs

+12-9
Original file line numberDiff line numberDiff line change
@@ -2318,18 +2318,21 @@ fn run_rustfmt(
23182318
}
23192319
};
23202320

2321-
tracing::debug!(?command, "created format command");
2321+
let output = {
2322+
let _p = tracing::info_span!("rustfmt", ?command).entered();
23222323

2323-
let mut rustfmt = command
2324-
.stdin(Stdio::piped())
2325-
.stdout(Stdio::piped())
2326-
.stderr(Stdio::piped())
2327-
.spawn()
2328-
.context(format!("Failed to spawn {command:?}"))?;
2324+
let mut rustfmt = command
2325+
.stdin(Stdio::piped())
2326+
.stdout(Stdio::piped())
2327+
.stderr(Stdio::piped())
2328+
.spawn()
2329+
.context(format!("Failed to spawn {command:?}"))?;
23292330

2330-
rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?;
2331+
rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?;
2332+
2333+
rustfmt.wait_with_output()?
2334+
};
23312335

2332-
let output = rustfmt.wait_with_output()?;
23332336
let captured_stdout = String::from_utf8(output.stdout)?;
23342337
let captured_stderr = String::from_utf8(output.stderr).unwrap_or_default();
23352338

Diff for: crates/rust-analyzer/src/reload.rs

+1-2
Original file line numberDiff line numberDiff line change
@@ -701,8 +701,7 @@ impl GlobalState {
701701

702702
let (crate_graph, proc_macro_paths, ws_data) = {
703703
// Create crate graph from all the workspaces
704-
let vfs = &mut self.vfs.write().0;
705-
704+
let vfs = &self.vfs.read().0;
706705
let load = |path: &AbsPath| {
707706
let vfs_path = vfs::VfsPath::from(path.to_path_buf());
708707
self.crate_graph_file_dependencies.insert(vfs_path.clone());

0 commit comments

Comments
 (0)