@@ -298,12 +298,23 @@ impl Step for Cargo {
298
298
299
299
/// Runs `cargo test` for `cargo` packaged with Rust.
300
300
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." ) ;
303
314
eprintln ! ( "HELP: consider using stage 2" ) ;
304
315
}
305
316
306
- let compiler = builder. compiler ( self . stage , self . host ) ;
317
+ let compiler = builder. compiler ( stage, self . host ) ;
307
318
308
319
let cargo = builder. ensure ( tool:: Cargo { compiler, target : self . host } ) ;
309
320
let compiler = cargo. build_compiler ;
@@ -340,7 +351,7 @@ impl Step for Cargo {
340
351
crates : vec ! [ "cargo" . into( ) ] ,
341
352
target : self . host . triple . to_string ( ) ,
342
353
host : self . host . triple . to_string ( ) ,
343
- stage : self . stage ,
354
+ stage,
344
355
} ,
345
356
builder,
346
357
) ;
@@ -744,7 +755,17 @@ impl Step for Clippy {
744
755
745
756
/// Runs `cargo test` for clippy.
746
757
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
+
748
769
let host = self . host ;
749
770
let compiler = builder. compiler ( stage, host) ;
750
771
0 commit comments