@@ -479,10 +479,11 @@ impl Command {
479479 Ok ( ( ) )
480480 }
481481
482- fn run ( dep : bool , flags : Vec < OsString > ) -> Result < ( ) > {
482+ fn run ( dep : bool , mut flags : Vec < OsString > ) -> Result < ( ) > {
483483 let mut e = MiriEnv :: new ( ) ?;
484484 // Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
485- // that we set the MIRI_SYSROOT up the right way.
485+ // that we set the MIRI_SYSROOT up the right way. We must make sure that
486+ // MIRI_TEST_TARGET and `--target` are in sync.
486487 use itertools:: Itertools ;
487488 let target = flags
488489 . iter ( )
@@ -493,33 +494,35 @@ impl Command {
493494 // Found it!
494495 e. sh . set_var ( "MIRI_TEST_TARGET" , target) ;
495496 } else if let Ok ( target) = std:: env:: var ( "MIRI_TEST_TARGET" ) {
496- // Make sure miri actually uses this target.
497- let miriflags = e . sh . var ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
498- e . sh . set_var ( "MIRIFLAGS" , format ! ( "{miriflags} -- target {target}" ) ) ;
497+ // Convert `MIRI_TEST_TARGET` into `-- target` .
498+ flags . push ( "--target" . into ( ) ) ;
499+ flags . push ( target. into ( ) ) ;
499500 }
500- // Scan for "--edition" (we'll set one ourselves if that flag is not present) .
501+ // Scan for "--edition", set one ourselves if that flag is not present.
501502 let have_edition =
502503 flags. iter ( ) . take_while ( |arg| * arg != "--" ) . any ( |arg| * arg == "--edition" ) ;
504+ if !have_edition {
505+ flags. push ( "--edition=2021" . into ( ) ) ; // keep in sync with `tests/ui.rs`.`
506+ }
503507
504508 // Prepare a sysroot.
505509 e. build_miri_sysroot ( /* quiet */ true ) ?;
506510
507- // Then run the actual command.
511+ // Then run the actual command. Also add MIRIFLAGS.
508512 let miri_manifest = path ! ( e. miri_dir / "Cargo.toml" ) ;
509513 let miri_flags = e. sh . var ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
510514 let miri_flags = flagsplit ( & miri_flags) ;
511515 let toolchain = & e. toolchain ;
512516 let extra_flags = & e. cargo_extra_flags ;
513- let edition_flags = ( !have_edition) . then_some ( "--edition=2021" ) ; // keep in sync with `tests/ui.rs`.`
514517 if dep {
515518 cmd ! (
516519 e. sh,
517- "cargo +{toolchain} --quiet test {extra_flags...} --manifest-path {miri_manifest} --test ui -- --miri-run-dep-mode {miri_flags...} {edition_flags...} { flags...}"
520+ "cargo +{toolchain} --quiet test {extra_flags...} --manifest-path {miri_manifest} --test ui -- --miri-run-dep-mode {miri_flags...} {flags...}"
518521 ) . quiet ( ) . run ( ) ?;
519522 } else {
520523 cmd ! (
521524 e. sh,
522- "cargo +{toolchain} --quiet run {extra_flags...} --manifest-path {miri_manifest} -- {miri_flags...} {edition_flags...} { flags...}"
525+ "cargo +{toolchain} --quiet run {extra_flags...} --manifest-path {miri_manifest} -- {miri_flags...} {flags...}"
523526 ) . quiet ( ) . run ( ) ?;
524527 }
525528 Ok ( ( ) )
0 commit comments