@@ -478,7 +478,11 @@ impl Command {
478478 // Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
479479 // that we set the MIRI_SYSROOT up the right way.
480480 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" ) ;
482486 if let Some ( ( _, target) ) = target {
483487 // Found it!
484488 e. sh . set_var ( "MIRI_TEST_TARGET" , target) ;
@@ -487,6 +491,10 @@ impl Command {
487491 let miriflags = e. sh . var ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
488492 e. sh . set_var ( "MIRIFLAGS" , format ! ( "{miriflags} --target {target}" ) ) ;
489493 }
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+
490498 // Prepare a sysroot.
491499 e. build_miri_sysroot ( /* quiet */ true ) ?;
492500
@@ -496,15 +504,16 @@ impl Command {
496504 let miri_flags = flagsplit ( & miri_flags) ;
497505 let toolchain = & e. toolchain ;
498506 let extra_flags = & e. cargo_extra_flags ;
507+ let edition_flags = ( !have_edition) . then_some ( "--edition=2021" ) ; // keep in sync with `compiletest.rs`.`
499508 if dep {
500509 cmd ! (
501510 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...}"
503512 ) . quiet ( ) . run ( ) ?;
504513 } else {
505514 cmd ! (
506515 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...}"
508517 ) . quiet ( ) . run ( ) ?;
509518 }
510519 Ok ( ( ) )
0 commit comments