@@ -1186,9 +1186,15 @@ fn symlink_dir_force(config: &Config, original: &Path, link: &Path) {
1186
1186
1187
1187
#[ derive( Ord , PartialOrd , Debug , Clone , Hash , PartialEq , Eq ) ]
1188
1188
pub 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
+ }
1192
1198
}
1193
1199
1194
1200
impl Step for RustcBook {
@@ -1202,8 +1208,17 @@ impl Step for RustcBook {
1202
1208
}
1203
1209
1204
1210
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
+
1205
1220
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 ) ,
1207
1222
target : run. target ,
1208
1223
validate : false ,
1209
1224
} ) ;
@@ -1221,10 +1236,10 @@ impl Step for RustcBook {
1221
1236
builder. cp_link_r ( & builder. src . join ( "src/doc/rustc" ) , & out_base) ;
1222
1237
builder. info ( & format ! ( "Generating lint docs ({})" , self . target) ) ;
1223
1238
1224
- let rustc = builder. rustc ( self . compiler ) ;
1239
+ let rustc = builder. rustc ( self . build_compiler ) ;
1225
1240
// The tool runs `rustc` for extracting output examples, so it needs a
1226
1241
// functional sysroot.
1227
- builder. std ( self . compiler , self . target ) ;
1242
+ builder. std ( self . build_compiler , self . target ) ;
1228
1243
let mut cmd = builder. tool_cmd ( Tool :: LintDocs ) ;
1229
1244
cmd. arg ( "--src" ) ;
1230
1245
cmd. arg ( builder. src . join ( "compiler" ) ) ;
@@ -1250,12 +1265,12 @@ impl Step for RustcBook {
1250
1265
// If the lib directories are in an unusual location (changed in
1251
1266
// bootstrap.toml), then this needs to explicitly update the dylib search
1252
1267
// path.
1253
- builder. add_rustc_lib_path ( self . compiler , & mut cmd) ;
1268
+ builder. add_rustc_lib_path ( self . build_compiler , & mut cmd) ;
1254
1269
let doc_generator_guard = builder. msg (
1255
1270
Kind :: Run ,
1256
- self . compiler . stage ,
1271
+ self . build_compiler . stage ,
1257
1272
"lint-docs" ,
1258
- self . compiler . host ,
1273
+ self . build_compiler . host ,
1259
1274
self . target ,
1260
1275
) ;
1261
1276
cmd. run ( builder) ;
0 commit comments