File tree Expand file tree Collapse file tree 4 files changed +30
-2
lines changed Expand file tree Collapse file tree 4 files changed +30
-2
lines changed Original file line number Diff line number Diff line change @@ -31,6 +31,7 @@ pub mod target_data_layout;
3131mod tests;
3232
3333use std:: {
34+ fmt,
3435 fs:: { self , read_dir, ReadDir } ,
3536 io,
3637 process:: Command ,
@@ -145,6 +146,16 @@ impl ProjectManifest {
145146 }
146147}
147148
149+ impl fmt:: Display for ProjectManifest {
150+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
151+ match self {
152+ ProjectManifest :: ProjectJson ( it) | ProjectManifest :: CargoToml ( it) => {
153+ fmt:: Display :: fmt ( & it, f)
154+ }
155+ }
156+ }
157+ }
158+
148159fn utf8_stdout ( mut cmd : Command ) -> Result < String > {
149160 let output = cmd. output ( ) . with_context ( || format ! ( "{cmd:?} failed" ) ) ?;
150161 if !output. status . success ( ) {
Original file line number Diff line number Diff line change 11//! See [`ManifestPath`].
2- use std:: { ops, path:: Path } ;
2+ use std:: { fmt , ops, path:: Path } ;
33
44use paths:: { AbsPath , AbsPathBuf } ;
55
@@ -40,6 +40,12 @@ impl ManifestPath {
4040 }
4141}
4242
43+ impl fmt:: Display for ManifestPath {
44+ fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
45+ fmt:: Display :: fmt ( & self . file . display ( ) , f)
46+ }
47+ }
48+
4349impl ops:: Deref for ManifestPath {
4450 type Target = AbsPath ;
4551
Original file line number Diff line number Diff line change @@ -151,6 +151,15 @@ impl ProjectWorkspace {
151151 manifest : ProjectManifest ,
152152 config : & CargoConfig ,
153153 progress : & dyn Fn ( String ) ,
154+ ) -> Result < ProjectWorkspace > {
155+ ProjectWorkspace :: load_inner ( & manifest, config, progress)
156+ . with_context ( || format ! ( "Failed to load the project at {manifest}" ) )
157+ }
158+
159+ fn load_inner (
160+ manifest : & ProjectManifest ,
161+ config : & CargoConfig ,
162+ progress : & dyn Fn ( String ) ,
154163 ) -> Result < ProjectWorkspace > {
155164 let version = |current_dir, cmd_path, prefix : & str | {
156165 let cargo_version = utf8_stdout ( {
Original file line number Diff line number Diff line change @@ -534,7 +534,9 @@ impl GlobalState {
534534 pub ( super ) fn fetch_workspace_error ( & self ) -> Result < ( ) , String > {
535535 let mut buf = String :: new ( ) ;
536536
537- let Some ( ( last_op_result, _) ) = self . fetch_workspaces_queue . last_op_result ( ) else { return Ok ( ( ) ) } ;
537+ let Some ( ( last_op_result, _) ) = self . fetch_workspaces_queue . last_op_result ( ) else {
538+ return Ok ( ( ) )
539+ } ;
538540 if last_op_result. is_empty ( ) {
539541 stdx:: format_to!( buf, "rust-analyzer failed to discover workspace" ) ;
540542 } else {
You can’t perform that action at this time.
0 commit comments