@@ -478,7 +478,11 @@ impl Command {
478
478
// Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
479
479
// that we set the MIRI_SYSROOT up the right way.
480
480
use itertools:: Itertools ;
481
- let target = flags. iter ( ) . tuple_windows ( ) . find ( |( first, _) | first == & "--target" ) ;
481
+ let target = flags
482
+ . iter ( )
483
+ . take_while ( |arg| * arg != "--" )
484
+ . tuple_windows ( )
485
+ . find ( |( first, _) | * first == "--target" ) ;
482
486
if let Some ( ( _, target) ) = target {
483
487
// Found it!
484
488
e. sh . set_var ( "MIRI_TEST_TARGET" , target) ;
@@ -487,6 +491,10 @@ impl Command {
487
491
let miriflags = e. sh . var ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
488
492
e. sh . set_var ( "MIRIFLAGS" , format ! ( "{miriflags} --target {target}" ) ) ;
489
493
}
494
+ // Scan for "--edition" (we'll set one ourselves if that flag is not present).
495
+ let have_edition =
496
+ flags. iter ( ) . take_while ( |arg| * arg != "--" ) . any ( |arg| * arg == "--edition" ) ;
497
+
490
498
// Prepare a sysroot.
491
499
e. build_miri_sysroot ( /* quiet */ true ) ?;
492
500
@@ -496,15 +504,16 @@ impl Command {
496
504
let miri_flags = flagsplit ( & miri_flags) ;
497
505
let toolchain = & e. toolchain ;
498
506
let extra_flags = & e. cargo_extra_flags ;
507
+ let edition_flags = ( !have_edition) . then_some ( "--edition=2021" ) ; // keep in sync with `compiletest.rs`.`
499
508
if dep {
500
509
cmd ! (
501
510
e. sh,
502
- "cargo +{toolchain} --quiet test --test compiletest {extra_flags...} --manifest-path {miri_manifest} -- --miri-run-dep-mode {miri_flags...} {flags...}"
511
+ "cargo +{toolchain} --quiet test --test compiletest {extra_flags...} --manifest-path {miri_manifest} -- --miri-run-dep-mode {miri_flags...} {edition_flags...} { flags...}"
503
512
) . quiet ( ) . run ( ) ?;
504
513
} else {
505
514
cmd ! (
506
515
e. sh,
507
- "cargo +{toolchain} --quiet run {extra_flags...} --manifest-path {miri_manifest} -- {miri_flags...} {flags...}"
516
+ "cargo +{toolchain} --quiet run {extra_flags...} --manifest-path {miri_manifest} -- {miri_flags...} {edition_flags...} { flags...}"
508
517
) . quiet ( ) . run ( ) ?;
509
518
}
510
519
Ok ( ( ) )
0 commit comments