@@ -451,6 +451,22 @@ impl Step for Std {
451451
452452 builder. run ( & mut cargo. into ( ) ) ;
453453 } ;
454+
455+ let paths = builder
456+ . paths
457+ . iter ( )
458+ . map ( components_simplified)
459+ . filter_map ( |path| {
460+ if path. get ( 0 ) == Some ( & "library" ) {
461+ Some ( path[ 1 ] . to_owned ( ) )
462+ } else if !path. is_empty ( ) {
463+ Some ( path[ 0 ] . to_owned ( ) )
464+ } else {
465+ None
466+ }
467+ } )
468+ . collect :: < Vec < _ > > ( ) ;
469+
454470 // Only build the following crates. While we could just iterate over the
455471 // folder structure, that would also build internal crates that we do
456472 // not want to show in documentation. These crates will later be visited
@@ -464,20 +480,17 @@ impl Step for Std {
464480 let krates = [ "core" , "alloc" , "std" , "proc_macro" , "test" ] ;
465481 for krate in & krates {
466482 run_cargo_rustdoc_for ( krate) ;
483+ if paths. iter ( ) . any ( |p| p == krate) {
484+ // No need to document more of the libraries if we have the one we want.
485+ break ;
486+ }
467487 }
468488 builder. cp_r ( & out_dir, & out) ;
469489
470490 // Look for library/std, library/core etc in the `x.py doc` arguments and
471491 // open the corresponding rendered docs.
472- for path in builder. paths . iter ( ) . map ( components_simplified) {
473- let requested_crate = if path. get ( 0 ) == Some ( & "library" ) {
474- & path[ 1 ]
475- } else if !path. is_empty ( ) {
476- & path[ 0 ]
477- } else {
478- continue ;
479- } ;
480- if krates. contains ( & requested_crate) {
492+ for requested_crate in paths {
493+ if krates. iter ( ) . any ( |k| * k == requested_crate. as_str ( ) ) {
481494 let index = out. join ( requested_crate) . join ( "index.html" ) ;
482495 open ( builder, & index) ;
483496 }
0 commit comments