@@ -1186,9 +1186,15 @@ fn symlink_dir_force(config: &Config, original: &Path, link: &Path) {
11861186
11871187#[ derive( Ord , PartialOrd , Debug , Clone , Hash , PartialEq , Eq ) ]
11881188pub struct RustcBook {
1189- pub compiler : Compiler ,
1190- pub target : TargetSelection ,
1191- pub validate : bool ,
1189+ build_compiler : Compiler ,
1190+ target : TargetSelection ,
1191+ validate : bool ,
1192+ }
1193+
1194+ impl RustcBook {
1195+ pub fn validate ( build_compiler : Compiler , target : TargetSelection ) -> Self {
1196+ Self { build_compiler, target, validate : true }
1197+ }
11921198}
11931199
11941200impl Step for RustcBook {
@@ -1202,8 +1208,17 @@ impl Step for RustcBook {
12021208 }
12031209
12041210 fn make_run ( run : RunConfig < ' _ > ) {
1211+ // Bump the stage to 2, because the rustc book requires an in-tree compiler.
1212+ // At the same time, since this step is enabled by default, we don't want `x doc` to fail
1213+ // in stage 1.
1214+ let stage = if run. builder . config . is_explicit_stage ( ) || run. builder . top_stage >= 2 {
1215+ run. builder . top_stage
1216+ } else {
1217+ 2
1218+ } ;
1219+
12051220 run. builder . ensure ( RustcBook {
1206- compiler : run . builder . compiler ( run. builder . top_stage , run. builder . config . host_target ) ,
1221+ build_compiler : prepare_doc_compiler ( run. builder , run. target , stage ) ,
12071222 target : run. target ,
12081223 validate : false ,
12091224 } ) ;
@@ -1221,10 +1236,10 @@ impl Step for RustcBook {
12211236 builder. cp_link_r ( & builder. src . join ( "src/doc/rustc" ) , & out_base) ;
12221237 builder. info ( & format ! ( "Generating lint docs ({})" , self . target) ) ;
12231238
1224- let rustc = builder. rustc ( self . compiler ) ;
1239+ let rustc = builder. rustc ( self . build_compiler ) ;
12251240 // The tool runs `rustc` for extracting output examples, so it needs a
12261241 // functional sysroot.
1227- builder. std ( self . compiler , self . target ) ;
1242+ builder. std ( self . build_compiler , self . target ) ;
12281243 let mut cmd = builder. tool_cmd ( Tool :: LintDocs ) ;
12291244 cmd. arg ( "--src" ) ;
12301245 cmd. arg ( builder. src . join ( "compiler" ) ) ;
@@ -1250,12 +1265,12 @@ impl Step for RustcBook {
12501265 // If the lib directories are in an unusual location (changed in
12511266 // bootstrap.toml), then this needs to explicitly update the dylib search
12521267 // path.
1253- builder. add_rustc_lib_path ( self . compiler , & mut cmd) ;
1268+ builder. add_rustc_lib_path ( self . build_compiler , & mut cmd) ;
12541269 let doc_generator_guard = builder. msg (
12551270 Kind :: Run ,
1256- self . compiler . stage ,
1271+ self . build_compiler . stage ,
12571272 "lint-docs" ,
1258- self . compiler . host ,
1273+ self . build_compiler . host ,
12591274 self . target ,
12601275 ) ;
12611276 cmd. run ( builder) ;
0 commit comments