@@ -537,7 +537,7 @@ impl Step for Rustc {
537
537
538
538
fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
539
539
let builder = run. builder ;
540
- run. krate ( "rustc-main" ) . default_condition ( builder. config . docs )
540
+ run. krate ( "rustc-main" ) . path ( "compiler" ) . default_condition ( builder. config . docs )
541
541
}
542
542
543
543
fn make_run ( run : RunConfig < ' _ > ) {
@@ -553,9 +553,24 @@ impl Step for Rustc {
553
553
fn run ( self , builder : & Builder < ' _ > ) {
554
554
let stage = self . stage ;
555
555
let target = self . target ;
556
+ let mut is_explicit_request = false ;
556
557
builder. info ( & format ! ( "Documenting stage{} compiler ({})" , stage, target) ) ;
557
558
558
- if !builder. config . compiler_docs {
559
+ let paths = builder
560
+ . paths
561
+ . iter ( )
562
+ . map ( components_simplified)
563
+ . filter_map ( |path| {
564
+ if path. get ( 0 ) == Some ( & "compiler" ) {
565
+ is_explicit_request = true ;
566
+ path. get ( 1 ) . map ( |p| p. to_owned ( ) )
567
+ } else {
568
+ None
569
+ }
570
+ } )
571
+ . collect :: < Vec < _ > > ( ) ;
572
+
573
+ if !builder. config . compiler_docs && !is_explicit_request {
559
574
builder. info ( "\t skipping - compiler/librustdoc docs disabled" ) ;
560
575
return ;
561
576
}
@@ -603,15 +618,34 @@ impl Step for Rustc {
603
618
cargo. rustdocflag ( "--extern-html-root-url" ) ;
604
619
cargo. rustdocflag ( "ena=https://docs.rs/ena/latest/" ) ;
605
620
606
- // Find dependencies for top level crates.
607
621
let mut compiler_crates = HashSet :: new ( ) ;
608
- for root_crate in & [ "rustc_driver" , "rustc_codegen_llvm" , "rustc_codegen_ssa" ] {
609
- compiler_crates. extend (
610
- builder
611
- . in_tree_crates ( root_crate, Some ( target) )
612
- . into_iter ( )
613
- . map ( |krate| krate. name ) ,
614
- ) ;
622
+
623
+ if paths. is_empty ( ) {
624
+ // Find dependencies for top level crates.
625
+ for root_crate in & [ "rustc_driver" , "rustc_codegen_llvm" , "rustc_codegen_ssa" ] {
626
+ compiler_crates. extend (
627
+ builder
628
+ . in_tree_crates ( root_crate, Some ( target) )
629
+ . into_iter ( )
630
+ . map ( |krate| krate. name ) ,
631
+ ) ;
632
+ }
633
+ } else {
634
+ for root_crate in paths {
635
+ if !builder. src . join ( "compiler" ) . join ( & root_crate) . exists ( ) {
636
+ builder. info ( & format ! (
637
+ "\t skipping - compiler/{} (unknown compiler crate)" ,
638
+ root_crate
639
+ ) ) ;
640
+ } else {
641
+ compiler_crates. extend (
642
+ builder
643
+ . in_tree_crates ( root_crate, Some ( target) )
644
+ . into_iter ( )
645
+ . map ( |krate| krate. name ) ,
646
+ ) ;
647
+ }
648
+ }
615
649
}
616
650
617
651
for krate in & compiler_crates {
0 commit comments