File tree 4 files changed +30
-2
lines changed
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;
31
31
mod tests;
32
32
33
33
use std:: {
34
+ fmt,
34
35
fs:: { self , read_dir, ReadDir } ,
35
36
io,
36
37
process:: Command ,
@@ -145,6 +146,16 @@ impl ProjectManifest {
145
146
}
146
147
}
147
148
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
+
148
159
fn utf8_stdout ( mut cmd : Command ) -> Result < String > {
149
160
let output = cmd. output ( ) . with_context ( || format ! ( "{cmd:?} failed" ) ) ?;
150
161
if !output. status . success ( ) {
Original file line number Diff line number Diff line change 1
1
//! See [`ManifestPath`].
2
- use std:: { ops, path:: Path } ;
2
+ use std:: { fmt , ops, path:: Path } ;
3
3
4
4
use paths:: { AbsPath , AbsPathBuf } ;
5
5
@@ -40,6 +40,12 @@ impl ManifestPath {
40
40
}
41
41
}
42
42
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
+
43
49
impl ops:: Deref for ManifestPath {
44
50
type Target = AbsPath ;
45
51
Original file line number Diff line number Diff line change @@ -151,6 +151,15 @@ impl ProjectWorkspace {
151
151
manifest : ProjectManifest ,
152
152
config : & CargoConfig ,
153
153
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 ) ,
154
163
) -> Result < ProjectWorkspace > {
155
164
let version = |current_dir, cmd_path, prefix : & str | {
156
165
let cargo_version = utf8_stdout ( {
Original file line number Diff line number Diff line change @@ -534,7 +534,9 @@ impl GlobalState {
534
534
pub ( super ) fn fetch_workspace_error ( & self ) -> Result < ( ) , String > {
535
535
let mut buf = String :: new ( ) ;
536
536
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
+ } ;
538
540
if last_op_result. is_empty ( ) {
539
541
stdx:: format_to!( buf, "rust-analyzer failed to discover workspace" ) ;
540
542
} else {
You can’t perform that action at this time.
0 commit comments