Skip to content

Commit 9f04957

Browse files
committed
Auto merge of rust-lang#16616 - Veykril:build-script-fix, r=Veykril
fix: server hanging up on build script task This should fix rust-lang/rust-analyzer#16614, can't say for certain since it might be not 100% reproducible... We really need to replace the current workspace fetching logic, it is completely unreadable and incredibly difficult to follow. I don't really understand how the server even got to hang here honestly (I would expect it to loop re-fetching build scripts, but not hang).
2 parents c888724 + 9dee352 commit 9f04957

File tree

3 files changed

+7
-21
lines changed

3 files changed

+7
-21
lines changed

crates/rust-analyzer/src/global_state.rs

+4-16
Original file line numberDiff line numberDiff line change
@@ -301,19 +301,12 @@ impl GlobalState {
301301
if let Some(path) = vfs_path.as_path() {
302302
let path = path.to_path_buf();
303303
if reload::should_refresh_for_change(&path, file.kind()) {
304-
workspace_structure_change = Some((
305-
path.clone(),
306-
false,
307-
AsRef::<std::path::Path>::as_ref(&path).ends_with("build.rs"),
308-
));
304+
workspace_structure_change = Some((path.clone(), false));
309305
}
310306
if file.is_created_or_deleted() {
311307
has_structure_changes = true;
312-
workspace_structure_change = Some((
313-
path,
314-
self.crate_graph_file_dependencies.contains(vfs_path),
315-
false,
316-
));
308+
workspace_structure_change =
309+
Some((path, self.crate_graph_file_dependencies.contains(vfs_path)));
317310
} else if path.extension() == Some("rs".as_ref()) {
318311
modified_rust_files.push(file.file_id);
319312
}
@@ -365,16 +358,11 @@ impl GlobalState {
365358
// FIXME: ideally we should only trigger a workspace fetch for non-library changes
366359
// but something's going wrong with the source root business when we add a new local
367360
// crate see https://github.com/rust-lang/rust-analyzer/issues/13029
368-
if let Some((path, force_crate_graph_reload, build_scripts_touched)) =
369-
workspace_structure_change
370-
{
361+
if let Some((path, force_crate_graph_reload)) = workspace_structure_change {
371362
self.fetch_workspaces_queue.request_op(
372363
format!("workspace vfs file change: {path}"),
373364
force_crate_graph_reload,
374365
);
375-
if build_scripts_touched {
376-
self.fetch_build_data_queue.request_op(format!("build.rs changed: {path}"), ());
377-
}
378366
}
379367
}
380368

crates/rust-analyzer/src/lsp/utils.rs

+1
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,7 @@ impl GlobalState {
134134
let token = lsp_types::ProgressToken::String(
135135
cancel_token.unwrap_or_else(|| format!("rustAnalyzer/{title}")),
136136
);
137+
tracing::debug!(?token, ?state, "report_progress {message:?}");
137138
let work_done_progress = match state {
138139
Progress::Begin => {
139140
self.send_request::<lsp_types::request::WorkDoneProgressCreate>(

crates/rust-analyzer/src/reload.rs

+2-5
Original file line numberDiff line numberDiff line change
@@ -411,10 +411,7 @@ impl GlobalState {
411411
if *force_reload_crate_graph {
412412
self.recreate_crate_graph(cause);
413413
}
414-
if self.build_deps_changed && self.config.run_build_scripts() {
415-
self.build_deps_changed = false;
416-
self.fetch_build_data_queue.request_op("build_deps_changed".to_owned(), ());
417-
}
414+
418415
// Current build scripts do not match the version of the active
419416
// workspace, so there's nothing for us to update.
420417
return;
@@ -424,7 +421,7 @@ impl GlobalState {
424421

425422
// Here, we completely changed the workspace (Cargo.toml edit), so
426423
// we don't care about build-script results, they are stale.
427-
// FIXME: can we abort the build scripts here?
424+
// FIXME: can we abort the build scripts here if they are already running?
428425
self.workspaces = Arc::new(workspaces);
429426

430427
if self.config.run_build_scripts() {

0 commit comments

Comments
 (0)