@@ -28,13 +28,16 @@ pub struct Std {
2828 /// passing `Builder::kind` to cargo invocations would run clippy on the entire compiler and library,
2929 /// which is not useful if we only want to lint a few crates with specific rules.
3030 override_build_kind : Option < Kind > ,
31+ /// Never use this from outside calls. It is intended for internal use only within `check::Std::make_run`
32+ /// and `check::Std::run`.
33+ custom_stage : Option < u32 > ,
3134}
3235
3336impl Std {
3437 const CRATE_OR_DEPS : & [ & str ] = & [ "sysroot" , "coretests" , "alloctests" ] ;
3538
3639 pub fn new ( target : TargetSelection ) -> Self {
37- Self { target, crates : vec ! [ ] , override_build_kind : None }
40+ Self { target, crates : vec ! [ ] , override_build_kind : None , custom_stage : None }
3841 }
3942
4043 pub fn build_kind ( mut self , kind : Option < Kind > ) -> Self {
@@ -48,34 +51,35 @@ impl Step for Std {
4851 const DEFAULT : bool = true ;
4952
5053 fn should_run ( run : ShouldRun < ' _ > ) -> ShouldRun < ' _ > {
51- let builder = run. builder ;
52- let stage = if builder. config . is_explicit_stage ( ) || builder. top_stage >= 1 {
53- builder. top_stage
54- } else {
55- 1
56- } ;
57-
5854 let mut run = run;
5955 for c in Std :: CRATE_OR_DEPS {
6056 run = run. crate_or_deps ( c) ;
6157 }
6258
63- run. path ( "library" ) . default_condition ( stage != 0 )
59+ run. path ( "library" )
6460 }
6561
6662 fn make_run ( run : RunConfig < ' _ > ) {
6763 let crates = std_crates_for_run_make ( & run) ;
68- run. builder . ensure ( Std { target : run. target , crates, override_build_kind : None } ) ;
64+
65+ let stage = if run. builder . config . is_explicit_stage ( ) || run. builder . top_stage >= 1 {
66+ run. builder . top_stage
67+ } else {
68+ 1
69+ } ;
70+
71+ run. builder . ensure ( Std {
72+ target : run. target ,
73+ crates,
74+ override_build_kind : None ,
75+ custom_stage : Some ( stage) ,
76+ } ) ;
6977 }
7078
7179 fn run ( self , builder : & Builder < ' _ > ) {
7280 builder. require_submodule ( "library/stdarch" , None ) ;
7381
74- let stage = if builder. config . is_explicit_stage ( ) || builder. top_stage >= 1 {
75- builder. top_stage
76- } else {
77- 1
78- } ;
82+ let stage = self . custom_stage . unwrap_or ( builder. top_stage ) ;
7983
8084 let target = self . target ;
8185 let compiler = builder. compiler ( stage, builder. config . build ) ;
0 commit comments