@@ -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 ,
@@ -210,7 +219,6 @@ impl Sysroot {
210219 & self ,
211220 sysroot_source_config : & RustSourceWorkspaceConfig ,
212221 no_deps : bool ,
213- current_dir : & AbsPath ,
214222 target_dir : & Utf8Path ,
215223 progress : & dyn Fn ( String ) ,
216224 ) -> Option < RustLibSrcWorkspace > {
@@ -224,7 +232,7 @@ impl Sysroot {
224232 if fs:: metadata ( & library_manifest) . is_ok ( ) {
225233 match self . load_library_via_cargo (
226234 & library_manifest,
227- current_dir ,
235+ src_root ,
228236 target_dir,
229237 cargo_config,
230238 no_deps,
@@ -294,7 +302,9 @@ impl Sysroot {
294302 && let Some ( src_root) = & self . rust_lib_src_root
295303 {
296304 let has_core = match & self . workspace {
297- 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+ }
298308 RustLibSrcWorkspace :: Json ( project_json) => project_json
299309 . crates ( )
300310 . filter_map ( |( _, krate) | krate. display_name . clone ( ) )
@@ -333,7 +343,7 @@ impl Sysroot {
333343
334344 // Make sure we never attempt to write to the sysroot
335345 let locked = true ;
336- let ( mut res, _ ) =
346+ let ( mut res, err ) =
337347 FetchMetadata :: new ( library_manifest, current_dir, & cargo_config, self , no_deps)
338348 . exec ( target_dir, locked, progress) ?;
339349
@@ -388,7 +398,10 @@ impl Sysroot {
388398
389399 let cargo_workspace =
390400 CargoWorkspace :: new ( res, library_manifest. clone ( ) , Default :: default ( ) , true ) ;
391- Ok ( RustLibSrcWorkspace :: Workspace ( cargo_workspace) )
401+ Ok ( RustLibSrcWorkspace :: Workspace {
402+ ws : cargo_workspace,
403+ metadata_err : err. map ( |e| format ! ( "{e:#}" ) ) ,
404+ } )
392405 }
393406}
394407
0 commit comments