@@ -12,7 +12,7 @@ use std::{env, fs, iter};
12
12
use build_helper:: exit;
13
13
14
14
use crate :: core:: build_steps:: compile:: { Std , run_cargo} ;
15
- use crate :: core:: build_steps:: doc:: DocumentationFormat ;
15
+ use crate :: core:: build_steps:: doc:: { DocumentationFormat , prepare_doc_compiler } ;
16
16
use crate :: core:: build_steps:: gcc:: { Gcc , add_cg_gcc_cargo_flags} ;
17
17
use crate :: core:: build_steps:: llvm:: get_llvm_version;
18
18
use crate :: core:: build_steps:: run:: get_completion_paths;
@@ -3273,8 +3273,8 @@ impl Step for TierCheck {
3273
3273
3274
3274
#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
3275
3275
pub struct LintDocs {
3276
- pub compiler : Compiler ,
3277
- pub target : TargetSelection ,
3276
+ build_compiler : Compiler ,
3277
+ target : TargetSelection ,
3278
3278
}
3279
3279
3280
3280
impl Step for LintDocs {
@@ -3287,17 +3287,36 @@ impl Step for LintDocs {
3287
3287
}
3288
3288
3289
3289
fn make_run ( run : RunConfig < ' _ > ) {
3290
+ // Bump the stage to 2, because the rustc book requires an in-tree compiler.
3291
+ // At the same time, since this step is enabled by default, we don't want `x test` to fail
3292
+ // in stage 1.
3293
+ let stage = if run. builder . config . is_explicit_stage ( ) || run. builder . top_stage >= 2 {
3294
+ run. builder . top_stage
3295
+ } else {
3296
+ 2
3297
+ } ;
3298
+
3290
3299
run. builder . ensure ( LintDocs {
3291
- compiler : run. builder . compiler ( run. builder . top_stage , run. builder . config . host_target ) ,
3300
+ build_compiler : prepare_doc_compiler (
3301
+ run. builder ,
3302
+ run. builder . config . host_target ,
3303
+ stage,
3304
+ ) ,
3292
3305
target : run. target ,
3293
3306
} ) ;
3294
3307
}
3295
3308
3296
3309
/// Tests that the lint examples in the rustc book generate the correct
3297
3310
/// lints and have the expected format.
3298
3311
fn run ( self , builder : & Builder < ' _ > ) {
3299
- builder
3300
- . ensure ( crate :: core:: build_steps:: doc:: RustcBook :: validate ( self . compiler , self . target ) ) ;
3312
+ builder. ensure ( crate :: core:: build_steps:: doc:: RustcBook :: validate (
3313
+ self . build_compiler ,
3314
+ self . target ,
3315
+ ) ) ;
3316
+ }
3317
+
3318
+ fn metadata ( & self ) -> Option < StepMetadata > {
3319
+ Some ( StepMetadata :: test ( "lint-docs" , self . target ) . built_by ( self . build_compiler ) )
3301
3320
}
3302
3321
}
3303
3322
0 commit comments