@@ -298,12 +298,23 @@ impl Step for Cargo {
298298
299299 /// Runs `cargo test` for `cargo` packaged with Rust.
300300 fn run ( self , builder : & Builder < ' _ > ) {
301- if self . stage < 2 {
302- eprintln ! ( "WARNING: cargo tests on stage {} may not behave well." , self . stage) ;
301+ // If stage is explicitly set or not lower than 2, keep it. Otherwise, make sure it's at least 2
302+ // as tests for this step don't work with a lower stage.
303+ let stage = if builder. config . explicit_stage_from_cli
304+ || builder. config . explicit_stage_from_config
305+ || self . stage >= 2
306+ {
307+ self . stage
308+ } else {
309+ 2
310+ } ;
311+
312+ if stage < 2 {
313+ eprintln ! ( "WARNING: cargo tests on stage {stage} may not behave well." ) ;
303314 eprintln ! ( "HELP: consider using stage 2" ) ;
304315 }
305316
306- let compiler = builder. compiler ( self . stage , self . host ) ;
317+ let compiler = builder. compiler ( stage, self . host ) ;
307318
308319 let cargo = builder. ensure ( tool:: Cargo { compiler, target : self . host } ) ;
309320 let compiler = cargo. build_compiler ;
@@ -340,7 +351,7 @@ impl Step for Cargo {
340351 crates : vec ! [ "cargo" . into( ) ] ,
341352 target : self . host . triple . to_string ( ) ,
342353 host : self . host . triple . to_string ( ) ,
343- stage : self . stage ,
354+ stage,
344355 } ,
345356 builder,
346357 ) ;
@@ -744,7 +755,17 @@ impl Step for Clippy {
744755
745756 /// Runs `cargo test` for clippy.
746757 fn run ( self , builder : & Builder < ' _ > ) {
747- let stage = self . stage ;
758+ // If stage is explicitly set or not lower than 2, keep it. Otherwise, make sure it's at least 2
759+ // as tests for this step don't work with a lower stage.
760+ let stage = if builder. config . explicit_stage_from_cli
761+ || builder. config . explicit_stage_from_config
762+ || self . stage >= 2
763+ {
764+ self . stage
765+ } else {
766+ 2
767+ } ;
768+
748769 let host = self . host ;
749770 let compiler = builder. compiler ( stage, host) ;
750771
0 commit comments