diff options
| author | Lukas Wirth <lukastw97@gmail.com> | 2025-02-02 10:04:57 +0100 |
|---|---|---|
| committer | Lukas Wirth <lukastw97@gmail.com> | 2025-02-02 10:04:57 +0100 |
| commit | acb9544ef852d479aebe94b0dcc14eb86bc3c597 (patch) | |
| tree | b6ff5dde77a0ac3c7efe7fbb656b95e280c723f3 | |
| parent | bec452fac1f5332baf145115eaa92e82bedf4d49 (diff) | |
| download | rust-acb9544ef852d479aebe94b0dcc14eb86bc3c597.tar.gz rust-acb9544ef852d479aebe94b0dcc14eb86bc3c597.zip | |
More rustfmt hang investigations
4 files changed, 18 insertions, 14 deletions
diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs index 0f2d7823b7e..b52f64aaace 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs @@ -396,6 +396,7 @@ impl GlobalState { || !self.config.same_source_root_parent_map(&self.local_roots_parent_map) { let config_change = { + let _p = span!(Level::INFO, "GlobalState::process_changes/config_change").entered(); let user_config_path = (|| { let mut p = Config::user_config_dir_path()?; p.push("rust-analyzer.toml"); @@ -569,12 +570,12 @@ impl GlobalState { if let Some((method, start)) = self.req_queue.incoming.complete(&response.id) { if let Some(err) = &response.error { if err.message.starts_with("server panicked") { - self.poke_rust_analyzer_developer(format!("{}, check the log", err.message)) + self.poke_rust_analyzer_developer(format!("{}, check the log", err.message)); } } let duration = start.elapsed(); - tracing::debug!("handled {} - ({}) in {:0.2?}", method, response.id, duration); + tracing::debug!(name: "message response", method, %response.id, duration = format_args!("{:0.2?}", duration)); self.send(response.into()); } } diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs index 84ba89d9f31..48856d19e15 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/notification.rs @@ -74,7 +74,8 @@ pub(crate) fn handle_did_open_text_document( tracing::error!("duplicate DidOpenTextDocument: {}", path); } - state.vfs.write().0.set_file_contents(path, Some(params.text_document.text.into_bytes())); + let contents = params.text_document.text.into_bytes(); + state.vfs.write().0.set_file_contents(path, Some(contents)); if state.config.discover_workspace_config().is_some() { tracing::debug!("queuing task"); let _ = state diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs index 39cbf53eaa2..ed028f1d37b 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/handlers/request.rs @@ -2318,18 +2318,21 @@ fn run_rustfmt( } }; - tracing::debug!(?command, "created format command"); + let output = { + let _p = tracing::info_span!("rustfmt", ?command).entered(); - let mut rustfmt = command - .stdin(Stdio::piped()) - .stdout(Stdio::piped()) - .stderr(Stdio::piped()) - .spawn() - .context(format!("Failed to spawn {command:?}"))?; + let mut rustfmt = command + .stdin(Stdio::piped()) + .stdout(Stdio::piped()) + .stderr(Stdio::piped()) + .spawn() + .context(format!("Failed to spawn {command:?}"))?; - rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?; + rustfmt.stdin.as_mut().unwrap().write_all(file.as_bytes())?; + + rustfmt.wait_with_output()? + }; - let output = rustfmt.wait_with_output()?; let captured_stdout = String::from_utf8(output.stdout)?; let captured_stderr = String::from_utf8(output.stderr).unwrap_or_default(); diff --git a/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs b/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs index 0add2cdf5a7..d18e5770477 100644 --- a/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs +++ b/src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs @@ -701,8 +701,7 @@ impl GlobalState { let (crate_graph, proc_macro_paths, ws_data) = { // Create crate graph from all the workspaces - let vfs = &mut self.vfs.write().0; - + let vfs = &self.vfs.read().0; let load = |path: &AbsPath| { let vfs_path = vfs::VfsPath::from(path.to_path_buf()); self.crate_graph_file_dependencies.insert(vfs_path.clone()); |
