@@ -579,17 +579,22 @@ impl Step for SharedAssets {
579579 }
580580}
581581
582+ /// Document the standard library using `build_compiler`.
582583#[ derive( Debug , Clone , Hash , PartialEq , Eq , PartialOrd , Ord ) ]
583584pub struct Std {
584- pub stage : u32 ,
585- pub target : TargetSelection ,
586- pub format : DocumentationFormat ,
585+ build_compiler : Compiler ,
586+ target : TargetSelection ,
587+ format : DocumentationFormat ,
587588 crates : Vec < String > ,
588589}
589590
590591impl Std {
591- pub ( crate ) fn new ( stage : u32 , target : TargetSelection , format : DocumentationFormat ) -> Self {
592- Std { stage, target, format, crates : vec ! [ ] }
592+ pub ( crate ) fn from_build_compiler (
593+ build_compiler : Compiler ,
594+ target : TargetSelection ,
595+ format : DocumentationFormat ,
596+ ) -> Self {
597+ Std { build_compiler, target, format, crates : vec ! [ ] }
593598 }
594599}
595600
@@ -609,7 +614,7 @@ impl Step for Std {
609614 return ;
610615 }
611616 run. builder . ensure ( Std {
612- stage : run. builder . top_stage ,
617+ build_compiler : run. builder . compiler ( run . builder . top_stage , run . builder . host_target ) ,
613618 target : run. target ,
614619 format : if run. builder . config . cmd . json ( ) {
615620 DocumentationFormat :: Json
@@ -625,7 +630,6 @@ impl Step for Std {
625630 /// This will generate all documentation for the standard library and its
626631 /// dependencies. This is largely just a wrapper around `cargo doc`.
627632 fn run ( self , builder : & Builder < ' _ > ) {
628- let stage = self . stage ;
629633 let target = self . target ;
630634 let crates = if self . crates . is_empty ( ) {
631635 builder
@@ -667,7 +671,7 @@ impl Step for Std {
667671 // For `--index-page` and `--output-format=json`.
668672 extra_args. push ( "-Zunstable-options" ) ;
669673
670- doc_std ( builder, self . format , stage , target, & out, & extra_args, & crates) ;
674+ doc_std ( builder, self . format , self . build_compiler , target, & out, & extra_args, & crates) ;
671675
672676 // Don't open if the format is json
673677 if let DocumentationFormat :: Json = self . format {
@@ -692,7 +696,7 @@ impl Step for Std {
692696 fn metadata ( & self ) -> Option < StepMetadata > {
693697 Some (
694698 StepMetadata :: doc ( "std" , self . target )
695- . stage ( self . stage )
699+ . built_by ( self . build_compiler )
696700 . with_metadata ( format ! ( "crates=[{}]" , self . crates. join( "," ) ) ) ,
697701 )
698702 }
@@ -728,24 +732,29 @@ impl DocumentationFormat {
728732fn doc_std (
729733 builder : & Builder < ' _ > ,
730734 format : DocumentationFormat ,
731- stage : u32 ,
735+ build_compiler : Compiler ,
732736 target : TargetSelection ,
733737 out : & Path ,
734738 extra_args : & [ & str ] ,
735739 requested_crates : & [ String ] ,
736740) {
737- let compiler = builder. compiler ( stage, builder. config . host_target ) ;
738-
739741 let target_doc_dir_name = if format == DocumentationFormat :: Json { "json-doc" } else { "doc" } ;
740- let target_dir = builder. stage_out ( compiler, Mode :: Std ) . join ( target) . join ( target_doc_dir_name) ;
742+ let target_dir =
743+ builder. stage_out ( build_compiler, Mode :: Std ) . join ( target) . join ( target_doc_dir_name) ;
741744
742745 // This is directory where the compiler will place the output of the command.
743746 // We will then copy the files from this directory into the final `out` directory, the specified
744747 // as a function parameter.
745748 let out_dir = target_dir. join ( target) . join ( "doc" ) ;
746749
747- let mut cargo =
748- builder:: Cargo :: new ( builder, compiler, Mode :: Std , SourceType :: InTree , target, Kind :: Doc ) ;
750+ let mut cargo = builder:: Cargo :: new (
751+ builder,
752+ build_compiler,
753+ Mode :: Std ,
754+ SourceType :: InTree ,
755+ target,
756+ Kind :: Doc ,
757+ ) ;
749758
750759 compile:: std_cargo ( builder, target, & mut cargo) ;
751760 cargo
@@ -773,7 +782,7 @@ fn doc_std(
773782
774783 let description =
775784 format ! ( "library{} in {} format" , crate_description( requested_crates) , format. as_str( ) ) ;
776- let _guard = builder. msg_doc ( compiler , description, target) ;
785+ let _guard = builder. msg_doc ( build_compiler , description, target) ;
777786
778787 cargo. into_cmd ( ) . run ( builder) ;
779788 builder. cp_link_r ( & out_dir, out) ;
0 commit comments