@@ -33,7 +33,7 @@ use vfs::{AbsPath, AbsPathBuf, ChangeKind};
3333use crate :: {
3434 config:: { Config , FilesWatcher , LinkedProject } ,
3535 flycheck:: { FlycheckConfig , FlycheckHandle } ,
36- global_state:: { FetchWorkspaceRequest , GlobalState } ,
36+ global_state:: { FetchWorkspaceRequest , FetchWorkspaceResponse , GlobalState } ,
3737 lsp_ext,
3838 main_loop:: { DiscoverProjectParam , Task } ,
3939 op_queue:: Cause ,
@@ -448,15 +448,15 @@ impl GlobalState {
448448 let _p = tracing:: info_span!( "GlobalState::switch_workspaces" ) . entered ( ) ;
449449 tracing:: info!( %cause, "will switch workspaces" ) ;
450450
451- let Some ( ( workspaces, force_reload_crate_graph ) ) =
451+ let Some ( FetchWorkspaceResponse { workspaces, force_crate_graph_reload } ) =
452452 self . fetch_workspaces_queue . last_op_result ( )
453453 else {
454454 return ;
455455 } ;
456456
457- info ! ( %cause, ?force_reload_crate_graph ) ;
457+ info ! ( %cause, ?force_crate_graph_reload ) ;
458458 if self . fetch_workspace_error ( ) . is_err ( ) && !self . workspaces . is_empty ( ) {
459- if * force_reload_crate_graph {
459+ if * force_crate_graph_reload {
460460 self . recreate_crate_graph ( cause) ;
461461 }
462462 // It only makes sense to switch to a partially broken workspace
@@ -474,8 +474,12 @@ impl GlobalState {
474474 . all ( |( l, r) | l. eq_ignore_build_data ( r) ) ;
475475
476476 if same_workspaces {
477- let ( workspaces, build_scripts) = self . fetch_build_data_queue . last_op_result ( ) ;
478- if Arc :: ptr_eq ( workspaces, & self . workspaces ) {
477+ let ( workspaces, build_scripts) = match self . fetch_build_data_queue . last_op_result ( ) {
478+ Some ( ( workspaces, build_scripts) ) => ( workspaces. clone ( ) , build_scripts. as_slice ( ) ) ,
479+ None => ( Default :: default ( ) , Default :: default ( ) ) ,
480+ } ;
481+
482+ if Arc :: ptr_eq ( & workspaces, & self . workspaces ) {
479483 info ! ( "set build scripts to workspaces" ) ;
480484
481485 let workspaces = workspaces
@@ -492,7 +496,7 @@ impl GlobalState {
492496 self . workspaces = Arc :: new ( workspaces) ;
493497 } else {
494498 info ! ( "build scripts do not match the version of the active workspace" ) ;
495- if * force_reload_crate_graph {
499+ if * force_crate_graph_reload {
496500 self . recreate_crate_graph ( cause) ;
497501 }
498502
@@ -739,14 +743,16 @@ impl GlobalState {
739743 pub ( super ) fn fetch_workspace_error ( & self ) -> Result < ( ) , String > {
740744 let mut buf = String :: new ( ) ;
741745
742- let Some ( ( last_op_result, _) ) = self . fetch_workspaces_queue . last_op_result ( ) else {
746+ let Some ( FetchWorkspaceResponse { workspaces, .. } ) =
747+ self . fetch_workspaces_queue . last_op_result ( )
748+ else {
743749 return Ok ( ( ) ) ;
744750 } ;
745751
746- if last_op_result . is_empty ( ) && self . config . discover_workspace_config ( ) . is_none ( ) {
752+ if workspaces . is_empty ( ) && self . config . discover_workspace_config ( ) . is_none ( ) {
747753 stdx:: format_to!( buf, "rust-analyzer failed to fetch workspace" ) ;
748754 } else {
749- for ws in last_op_result {
755+ for ws in workspaces {
750756 if let Err ( err) = ws {
751757 stdx:: format_to!( buf, "rust-analyzer failed to load workspace: {:#}\n " , err) ;
752758 }
@@ -763,7 +769,11 @@ impl GlobalState {
763769 pub ( super ) fn fetch_build_data_error ( & self ) -> Result < ( ) , String > {
764770 let mut buf = String :: new ( ) ;
765771
766- for ws in & self . fetch_build_data_queue . last_op_result ( ) . 1 {
772+ let Some ( ( _, ws) ) = & self . fetch_build_data_queue . last_op_result ( ) else {
773+ return Ok ( ( ) ) ;
774+ } ;
775+
776+ for ws in ws {
767777 match ws {
768778 Ok ( data) => {
769779 if let Some ( stderr) = data. error ( ) {
0 commit comments