@@ -33,7 +33,7 @@ use vfs::{AbsPath, AbsPathBuf, ChangeKind};
33
33
use crate :: {
34
34
config:: { Config , FilesWatcher , LinkedProject } ,
35
35
flycheck:: { FlycheckConfig , FlycheckHandle } ,
36
- global_state:: { FetchWorkspaceRequest , GlobalState } ,
36
+ global_state:: { FetchWorkspaceRequest , FetchWorkspaceResponse , GlobalState } ,
37
37
lsp_ext,
38
38
main_loop:: { DiscoverProjectParam , Task } ,
39
39
op_queue:: Cause ,
@@ -448,15 +448,15 @@ impl GlobalState {
448
448
let _p = tracing:: info_span!( "GlobalState::switch_workspaces" ) . entered ( ) ;
449
449
tracing:: info!( %cause, "will switch workspaces" ) ;
450
450
451
- let Some ( ( workspaces, force_reload_crate_graph ) ) =
451
+ let Some ( FetchWorkspaceResponse { workspaces, force_crate_graph_reload } ) =
452
452
self . fetch_workspaces_queue . last_op_result ( )
453
453
else {
454
454
return ;
455
455
} ;
456
456
457
- info ! ( %cause, ?force_reload_crate_graph ) ;
457
+ info ! ( %cause, ?force_crate_graph_reload ) ;
458
458
if self . fetch_workspace_error ( ) . is_err ( ) && !self . workspaces . is_empty ( ) {
459
- if * force_reload_crate_graph {
459
+ if * force_crate_graph_reload {
460
460
self . recreate_crate_graph ( cause) ;
461
461
}
462
462
// It only makes sense to switch to a partially broken workspace
@@ -474,8 +474,12 @@ impl GlobalState {
474
474
. all ( |( l, r) | l. eq_ignore_build_data ( r) ) ;
475
475
476
476
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 ) {
479
483
info ! ( "set build scripts to workspaces" ) ;
480
484
481
485
let workspaces = workspaces
@@ -492,7 +496,7 @@ impl GlobalState {
492
496
self . workspaces = Arc :: new ( workspaces) ;
493
497
} else {
494
498
info ! ( "build scripts do not match the version of the active workspace" ) ;
495
- if * force_reload_crate_graph {
499
+ if * force_crate_graph_reload {
496
500
self . recreate_crate_graph ( cause) ;
497
501
}
498
502
@@ -739,14 +743,16 @@ impl GlobalState {
739
743
pub ( super ) fn fetch_workspace_error ( & self ) -> Result < ( ) , String > {
740
744
let mut buf = String :: new ( ) ;
741
745
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 {
743
749
return Ok ( ( ) ) ;
744
750
} ;
745
751
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 ( ) {
747
753
stdx:: format_to!( buf, "rust-analyzer failed to fetch workspace" ) ;
748
754
} else {
749
- for ws in last_op_result {
755
+ for ws in workspaces {
750
756
if let Err ( err) = ws {
751
757
stdx:: format_to!( buf, "rust-analyzer failed to load workspace: {:#}\n " , err) ;
752
758
}
@@ -763,7 +769,11 @@ impl GlobalState {
763
769
pub ( super ) fn fetch_build_data_error ( & self ) -> Result < ( ) , String > {
764
770
let mut buf = String :: new ( ) ;
765
771
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 {
767
777
match ws {
768
778
Ok ( data) => {
769
779
if let Some ( stderr) = data. error ( ) {
0 commit comments