@@ -1200,9 +1200,15 @@ fn symlink_dir_force(config: &Config, original: &Path, link: &Path) {
12001200
12011201#[ derive( Ord , PartialOrd , Debug , Clone , Hash , PartialEq , Eq ) ]
12021202pub struct RustcBook {
1203- pub compiler : Compiler ,
1204- pub target : TargetSelection ,
1205- pub validate : bool ,
1203+ build_compiler : Compiler ,
1204+ target : TargetSelection ,
1205+ validate : bool ,
1206+ }
1207+
1208+ impl RustcBook {
1209+ pub fn validate ( build_compiler : Compiler , target : TargetSelection ) -> Self {
1210+ Self { build_compiler, target, validate : true }
1211+ }
12061212}
12071213
12081214impl Step for RustcBook {
@@ -1216,8 +1222,17 @@ impl Step for RustcBook {
12161222 }
12171223
12181224 fn make_run ( run : RunConfig < ' _ > ) {
1225+ // Bump the stage to 2, because the rustc book requires an in-tree compiler.
1226+ // At the same time, since this step is enabled by default, we don't want `x doc` to fail
1227+ // in stage 1.
1228+ let stage = if run. builder . config . is_explicit_stage ( ) || run. builder . top_stage >= 2 {
1229+ run. builder . top_stage
1230+ } else {
1231+ 2
1232+ } ;
1233+
12191234 run. builder . ensure ( RustcBook {
1220- compiler : run . builder . compiler ( run. builder . top_stage , run. builder . config . host_target ) ,
1235+ build_compiler : prepare_doc_compiler ( run. builder , run. target , stage ) ,
12211236 target : run. target ,
12221237 validate : false ,
12231238 } ) ;
@@ -1235,10 +1250,10 @@ impl Step for RustcBook {
12351250 builder. cp_link_r ( & builder. src . join ( "src/doc/rustc" ) , & out_base) ;
12361251 builder. info ( & format ! ( "Generating lint docs ({})" , self . target) ) ;
12371252
1238- let rustc = builder. rustc ( self . compiler ) ;
1253+ let rustc = builder. rustc ( self . build_compiler ) ;
12391254 // The tool runs `rustc` for extracting output examples, so it needs a
12401255 // functional sysroot.
1241- builder. std ( self . compiler , self . target ) ;
1256+ builder. std ( self . build_compiler , self . target ) ;
12421257 let mut cmd = builder. tool_cmd ( Tool :: LintDocs ) ;
12431258 cmd. arg ( "--src" ) ;
12441259 cmd. arg ( builder. src . join ( "compiler" ) ) ;
@@ -1264,12 +1279,12 @@ impl Step for RustcBook {
12641279 // If the lib directories are in an unusual location (changed in
12651280 // bootstrap.toml), then this needs to explicitly update the dylib search
12661281 // path.
1267- builder. add_rustc_lib_path ( self . compiler , & mut cmd) ;
1282+ builder. add_rustc_lib_path ( self . build_compiler , & mut cmd) ;
12681283 let doc_generator_guard = builder. msg (
12691284 Kind :: Run ,
1270- self . compiler . stage ,
1285+ self . build_compiler . stage ,
12711286 "lint-docs" ,
1272- self . compiler . host ,
1287+ self . build_compiler . host ,
12731288 self . target ,
12741289 ) ;
12751290 cmd. run ( builder) ;
0 commit comments