@@ -30,7 +30,7 @@ pub struct Sysroot {
3030
3131#[ derive( Debug , Clone , Eq , PartialEq ) ]
3232pub enum RustLibSrcWorkspace {
33- Workspace ( CargoWorkspace ) ,
33+ Workspace { ws : CargoWorkspace , metadata_err : Option < String > } ,
3434 Json ( ProjectJson ) ,
3535 Stitched ( stitched:: Stitched ) ,
3636 Empty ,
@@ -39,7 +39,9 @@ pub enum RustLibSrcWorkspace {
3939impl fmt:: Display for RustLibSrcWorkspace {
4040 fn fmt ( & self , f : & mut fmt:: Formatter < ' _ > ) -> fmt:: Result {
4141 match self {
42- RustLibSrcWorkspace :: Workspace ( ws) => write ! ( f, "workspace {}" , ws. workspace_root( ) ) ,
42+ RustLibSrcWorkspace :: Workspace { ws, .. } => {
43+ write ! ( f, "workspace {}" , ws. workspace_root( ) )
44+ }
4345 RustLibSrcWorkspace :: Json ( json) => write ! ( f, "json {}" , json. manifest_or_root( ) ) ,
4446 RustLibSrcWorkspace :: Stitched ( stitched) => {
4547 write ! ( f, "stitched with {} crates" , stitched. crates. len( ) )
@@ -74,7 +76,7 @@ impl Sysroot {
7476
7577 pub fn is_rust_lib_src_empty ( & self ) -> bool {
7678 match & self . workspace {
77- RustLibSrcWorkspace :: Workspace ( ws ) => ws. packages ( ) . next ( ) . is_none ( ) ,
79+ RustLibSrcWorkspace :: Workspace { ws , .. } => ws. packages ( ) . next ( ) . is_none ( ) ,
7880 RustLibSrcWorkspace :: Json ( project_json) => project_json. n_crates ( ) == 0 ,
7981 RustLibSrcWorkspace :: Stitched ( stitched) => stitched. crates . is_empty ( ) ,
8082 RustLibSrcWorkspace :: Empty => true ,
@@ -85,9 +87,16 @@ impl Sysroot {
8587 self . error . as_deref ( )
8688 }
8789
90+ pub fn metadata_error ( & self ) -> Option < & str > {
91+ match & self . workspace {
92+ RustLibSrcWorkspace :: Workspace { metadata_err, .. } => metadata_err. as_deref ( ) ,
93+ _ => None ,
94+ }
95+ }
96+
8897 pub fn num_packages ( & self ) -> usize {
8998 match & self . workspace {
90- RustLibSrcWorkspace :: Workspace ( ws ) => ws. packages ( ) . count ( ) ,
99+ RustLibSrcWorkspace :: Workspace { ws , .. } => ws. packages ( ) . count ( ) ,
91100 RustLibSrcWorkspace :: Json ( project_json) => project_json. n_crates ( ) ,
92101 RustLibSrcWorkspace :: Stitched ( stitched) => stitched. crates . len ( ) ,
93102 RustLibSrcWorkspace :: Empty => 0 ,
@@ -293,7 +302,9 @@ impl Sysroot {
293302 && let Some ( src_root) = & self . rust_lib_src_root
294303 {
295304 let has_core = match & self . workspace {
296- RustLibSrcWorkspace :: Workspace ( ws) => ws. packages ( ) . any ( |p| ws[ p] . name == "core" ) ,
305+ RustLibSrcWorkspace :: Workspace { ws : workspace, .. } => {
306+ workspace. packages ( ) . any ( |p| workspace[ p] . name == "core" )
307+ }
297308 RustLibSrcWorkspace :: Json ( project_json) => project_json
298309 . crates ( )
299310 . filter_map ( |( _, krate) | krate. display_name . clone ( ) )
@@ -332,7 +343,7 @@ impl Sysroot {
332343
333344 // Make sure we never attempt to write to the sysroot
334345 let locked = true ;
335- let ( mut res, _ ) =
346+ let ( mut res, err ) =
336347 FetchMetadata :: new ( library_manifest, current_dir, & cargo_config, self , no_deps)
337348 . exec ( target_dir, locked, progress) ?;
338349
@@ -387,7 +398,10 @@ impl Sysroot {
387398
388399 let cargo_workspace =
389400 CargoWorkspace :: new ( res, library_manifest. clone ( ) , Default :: default ( ) , true ) ;
390- Ok ( RustLibSrcWorkspace :: Workspace ( cargo_workspace) )
401+ Ok ( RustLibSrcWorkspace :: Workspace {
402+ ws : cargo_workspace,
403+ metadata_err : err. map ( |e| format ! ( "{e:#}" ) ) ,
404+ } )
391405 }
392406}
393407
0 commit comments