@@ -451,6 +451,22 @@ impl Step for Std {
451
451
452
452
builder. run ( & mut cargo. into ( ) ) ;
453
453
} ;
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
+
454
470
// Only build the following crates. While we could just iterate over the
455
471
// folder structure, that would also build internal crates that we do
456
472
// not want to show in documentation. These crates will later be visited
@@ -464,20 +480,17 @@ impl Step for Std {
464
480
let krates = [ "core" , "alloc" , "std" , "proc_macro" , "test" ] ;
465
481
for krate in & krates {
466
482
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
+ }
467
487
}
468
488
builder. cp_r ( & out_dir, & out) ;
469
489
470
490
// Look for library/std, library/core etc in the `x.py doc` arguments and
471
491
// 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 ( ) ) {
481
494
let index = out. join ( requested_crate) . join ( "index.html" ) ;
482
495
open ( builder, & index) ;
483
496
}
0 commit comments