Skip to content

Commit d3531e8

Browse files
committed
Auto merge of rust-lang#13605 - Veykril:empty-ws-error, r=Veykril
fix: Fix r-a eagerly showing no discovered workspace errors
2 parents add8539 + a143ff0 commit d3531e8

File tree

3 files changed

+6
-9
lines changed

3 files changed

+6
-9
lines changed

crates/rust-analyzer/src/global_state.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ pub(crate) struct GlobalState {
100100
/// the user just adds comments or whitespace to Cargo.toml, we do not want
101101
/// to invalidate any salsa caches.
102102
pub(crate) workspaces: Arc<Vec<ProjectWorkspace>>,
103-
pub(crate) fetch_workspaces_queue: OpQueue<Vec<anyhow::Result<ProjectWorkspace>>>,
103+
pub(crate) fetch_workspaces_queue: OpQueue<Option<Vec<anyhow::Result<ProjectWorkspace>>>>,
104104
pub(crate) fetch_build_data_queue:
105105
OpQueue<(Arc<Vec<ProjectWorkspace>>, Vec<anyhow::Result<WorkspaceBuildScripts>>)>,
106106

crates/rust-analyzer/src/main_loop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -451,7 +451,7 @@ impl GlobalState {
451451
ProjectWorkspaceProgress::Begin => (Progress::Begin, None),
452452
ProjectWorkspaceProgress::Report(msg) => (Progress::Report, Some(msg)),
453453
ProjectWorkspaceProgress::End(workspaces) => {
454-
self.fetch_workspaces_queue.op_completed(workspaces);
454+
self.fetch_workspaces_queue.op_completed(Some(workspaces));
455455

456456
let old = Arc::clone(&self.workspaces);
457457
self.switch_workspaces("fetched workspace".to_string());

crates/rust-analyzer/src/reload.rs

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,9 @@ impl GlobalState {
206206
self.show_and_log_error("failed to run build scripts".to_string(), Some(error));
207207
}
208208

209-
let workspaces = self
210-
.fetch_workspaces_queue
211-
.last_op_result()
212-
.iter()
213-
.filter_map(|res| res.as_ref().ok().cloned())
214-
.collect::<Vec<_>>();
209+
let Some(workspaces) = self.fetch_workspaces_queue.last_op_result() else { return; };
210+
let workspaces =
211+
workspaces.iter().filter_map(|res| res.as_ref().ok().cloned()).collect::<Vec<_>>();
215212

216213
fn eq_ignore_build_data<'a>(
217214
left: &'a ProjectWorkspace,
@@ -435,7 +432,7 @@ impl GlobalState {
435432
fn fetch_workspace_error(&self) -> Result<(), String> {
436433
let mut buf = String::new();
437434

438-
let last_op_result = self.fetch_workspaces_queue.last_op_result();
435+
let Some(last_op_result) = self.fetch_workspaces_queue.last_op_result() else { return Ok(()) };
439436
if last_op_result.is_empty() {
440437
stdx::format_to!(buf, "rust-analyzer failed to discover workspace");
441438
} else {

0 commit comments

Comments
 (0)