@@ -1200,9 +1200,15 @@ fn symlink_dir_force(config: &Config, original: &Path, link: &Path) {
1200
1200
1201
1201
#[ derive( Ord , PartialOrd , Debug , Clone , Hash , PartialEq , Eq ) ]
1202
1202
pub 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
+ }
1206
1212
}
1207
1213
1208
1214
impl Step for RustcBook {
@@ -1216,8 +1222,17 @@ impl Step for RustcBook {
1216
1222
}
1217
1223
1218
1224
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
+
1219
1234
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 ) ,
1221
1236
target : run. target ,
1222
1237
validate : false ,
1223
1238
} ) ;
@@ -1235,10 +1250,10 @@ impl Step for RustcBook {
1235
1250
builder. cp_link_r ( & builder. src . join ( "src/doc/rustc" ) , & out_base) ;
1236
1251
builder. info ( & format ! ( "Generating lint docs ({})" , self . target) ) ;
1237
1252
1238
- let rustc = builder. rustc ( self . compiler ) ;
1253
+ let rustc = builder. rustc ( self . build_compiler ) ;
1239
1254
// The tool runs `rustc` for extracting output examples, so it needs a
1240
1255
// functional sysroot.
1241
- builder. std ( self . compiler , self . target ) ;
1256
+ builder. std ( self . build_compiler , self . target ) ;
1242
1257
let mut cmd = builder. tool_cmd ( Tool :: LintDocs ) ;
1243
1258
cmd. arg ( "--src" ) ;
1244
1259
cmd. arg ( builder. src . join ( "compiler" ) ) ;
@@ -1264,12 +1279,12 @@ impl Step for RustcBook {
1264
1279
// If the lib directories are in an unusual location (changed in
1265
1280
// bootstrap.toml), then this needs to explicitly update the dylib search
1266
1281
// path.
1267
- builder. add_rustc_lib_path ( self . compiler , & mut cmd) ;
1282
+ builder. add_rustc_lib_path ( self . build_compiler , & mut cmd) ;
1268
1283
let doc_generator_guard = builder. msg (
1269
1284
Kind :: Run ,
1270
- self . compiler . stage ,
1285
+ self . build_compiler . stage ,
1271
1286
"lint-docs" ,
1272
- self . compiler . host ,
1287
+ self . build_compiler . host ,
1273
1288
self . target ,
1274
1289
) ;
1275
1290
cmd. run ( builder) ;
0 commit comments