Skip to content

Commit 1a354f6

Browse files
committed
Auto merge of rust-lang#18216 - davidbarsky:davidbarsky/push-ustyovtqrpoq, r=davidbarsky
internal: switch remaining OpQueues to use named structs Building atop of rust-lang/rust-analyzer#18195, I switched `GlobalState::fetch_build_data_queue` to use a struct instead of a tuple. (I didn't switch `fetch_proc_macros_queue` to not return a bool, as the return value is only used in one spot.)
2 parents d764d87 + efd8e15 commit 1a354f6

File tree

3 files changed

+23
-10
lines changed

3 files changed

+23
-10
lines changed

src/tools/rust-analyzer/crates/rust-analyzer/src/global_state.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,11 @@ pub(crate) struct FetchWorkspaceResponse {
5151
pub(crate) force_crate_graph_reload: bool,
5252
}
5353

54+
pub(crate) struct FetchBuildDataResponse {
55+
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
56+
pub(crate) build_scripts: Vec<anyhow::Result<WorkspaceBuildScripts>>,
57+
}
58+
5459
// Enforces drop order
5560
pub(crate) struct Handle<H, C> {
5661
pub(crate) handle: H,
@@ -152,8 +157,7 @@ pub(crate) struct GlobalState {
152157

153158
// op queues
154159
pub(crate) fetch_workspaces_queue: OpQueue<FetchWorkspaceRequest, FetchWorkspaceResponse>,
155-
pub(crate) fetch_build_data_queue:
156-
OpQueue<(), (Arc<Vec<ProjectWorkspace>>, Vec<anyhow::Result<WorkspaceBuildScripts>>)>,
160+
pub(crate) fetch_build_data_queue: OpQueue<(), FetchBuildDataResponse>,
157161
pub(crate) fetch_proc_macros_queue: OpQueue<Vec<ProcMacroPaths>, bool>,
158162
pub(crate) prime_caches_queue: OpQueue,
159163
pub(crate) discover_workspace_queue: OpQueue,

src/tools/rust-analyzer/crates/rust-analyzer/src/main_loop.rs

+6-3
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,8 @@ use crate::{
2323
discover::{DiscoverArgument, DiscoverCommand, DiscoverProjectMessage},
2424
flycheck::{self, FlycheckMessage},
2525
global_state::{
26-
file_id_to_url, url_to_file_id, FetchWorkspaceRequest, FetchWorkspaceResponse, GlobalState,
26+
file_id_to_url, url_to_file_id, FetchBuildDataResponse, FetchWorkspaceRequest,
27+
FetchWorkspaceResponse, GlobalState,
2728
},
2829
hack_recover_crate_name,
2930
handlers::dispatch::{NotificationDispatcher, RequestDispatcher},
@@ -738,8 +739,10 @@ impl GlobalState {
738739
let (state, msg) = match progress {
739740
BuildDataProgress::Begin => (Some(Progress::Begin), None),
740741
BuildDataProgress::Report(msg) => (Some(Progress::Report), Some(msg)),
741-
BuildDataProgress::End(build_data_result) => {
742-
self.fetch_build_data_queue.op_completed(build_data_result);
742+
BuildDataProgress::End((workspaces, build_scripts)) => {
743+
let resp = FetchBuildDataResponse { workspaces, build_scripts };
744+
self.fetch_build_data_queue.op_completed(resp);
745+
743746
if let Err(e) = self.fetch_build_data_error() {
744747
error!("FetchBuildDataError: {e}");
745748
}

src/tools/rust-analyzer/crates/rust-analyzer/src/reload.rs

+11-5
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,9 @@ use vfs::{AbsPath, AbsPathBuf, ChangeKind};
3333
use crate::{
3434
config::{Config, FilesWatcher, LinkedProject},
3535
flycheck::{FlycheckConfig, FlycheckHandle},
36-
global_state::{FetchWorkspaceRequest, FetchWorkspaceResponse, GlobalState},
36+
global_state::{
37+
FetchBuildDataResponse, FetchWorkspaceRequest, FetchWorkspaceResponse, GlobalState,
38+
},
3739
lsp_ext,
3840
main_loop::{DiscoverProjectParam, Task},
3941
op_queue::Cause,
@@ -475,7 +477,9 @@ impl GlobalState {
475477

476478
if same_workspaces {
477479
let (workspaces, build_scripts) = match self.fetch_build_data_queue.last_op_result() {
478-
Some((workspaces, build_scripts)) => (workspaces.clone(), build_scripts.as_slice()),
480+
Some(FetchBuildDataResponse { workspaces, build_scripts }) => {
481+
(workspaces.clone(), build_scripts.as_slice())
482+
}
479483
None => (Default::default(), Default::default()),
480484
};
481485

@@ -769,12 +773,14 @@ impl GlobalState {
769773
pub(super) fn fetch_build_data_error(&self) -> Result<(), String> {
770774
let mut buf = String::new();
771775

772-
let Some((_, ws)) = &self.fetch_build_data_queue.last_op_result() else {
776+
let Some(FetchBuildDataResponse { build_scripts, .. }) =
777+
&self.fetch_build_data_queue.last_op_result()
778+
else {
773779
return Ok(());
774780
};
775781

776-
for ws in ws {
777-
match ws {
782+
for script in build_scripts {
783+
match script {
778784
Ok(data) => {
779785
if let Some(stderr) = data.error() {
780786
stdx::format_to!(buf, "{:#}\n", stderr)

0 commit comments

Comments
 (0)