@@ -12,7 +12,7 @@ use std::{env, fs, iter};
1212use build_helper:: exit;
1313
1414use 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 } ;
1616use crate :: core:: build_steps:: gcc:: { Gcc , add_cg_gcc_cargo_flags} ;
1717use crate :: core:: build_steps:: llvm:: get_llvm_version;
1818use crate :: core:: build_steps:: run:: get_completion_paths;
@@ -3304,8 +3304,8 @@ impl Step for TierCheck {
33043304
33053305#[ derive( Debug , Clone , PartialEq , Eq , Hash ) ]
33063306pub struct LintDocs {
3307- pub compiler : Compiler ,
3308- pub target : TargetSelection ,
3307+ build_compiler : Compiler ,
3308+ target : TargetSelection ,
33093309}
33103310
33113311impl Step for LintDocs {
@@ -3318,17 +3318,36 @@ impl Step for LintDocs {
33183318 }
33193319
33203320 fn make_run ( run : RunConfig < ' _ > ) {
3321+ // Bump the stage to 2, because the rustc book requires an in-tree compiler.
3322+ // At the same time, since this step is enabled by default, we don't want `x test` to fail
3323+ // in stage 1.
3324+ let stage = if run. builder . config . is_explicit_stage ( ) || run. builder . top_stage >= 2 {
3325+ run. builder . top_stage
3326+ } else {
3327+ 2
3328+ } ;
3329+
33213330 run. builder . ensure ( LintDocs {
3322- compiler : run. builder . compiler ( run. builder . top_stage , run. builder . config . host_target ) ,
3331+ build_compiler : prepare_doc_compiler (
3332+ run. builder ,
3333+ run. builder . config . host_target ,
3334+ stage,
3335+ ) ,
33233336 target : run. target ,
33243337 } ) ;
33253338 }
33263339
33273340 /// Tests that the lint examples in the rustc book generate the correct
33283341 /// lints and have the expected format.
33293342 fn run ( self , builder : & Builder < ' _ > ) {
3330- builder
3331- . ensure ( crate :: core:: build_steps:: doc:: RustcBook :: validate ( self . compiler , self . target ) ) ;
3343+ builder. ensure ( crate :: core:: build_steps:: doc:: RustcBook :: validate (
3344+ self . build_compiler ,
3345+ self . target ,
3346+ ) ) ;
3347+ }
3348+
3349+ fn metadata ( & self ) -> Option < StepMetadata > {
3350+ Some ( StepMetadata :: test ( "lint-docs" , self . target ) . built_by ( self . build_compiler ) )
33323351 }
33333352}
33343353
0 commit comments