@@ -479,10 +479,11 @@ impl Command {
479
479
Ok ( ( ) )
480
480
}
481
481
482
- fn run ( dep : bool , flags : Vec < OsString > ) -> Result < ( ) > {
482
+ fn run ( dep : bool , mut flags : Vec < OsString > ) -> Result < ( ) > {
483
483
let mut e = MiriEnv :: new ( ) ?;
484
484
// 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.
486
487
use itertools:: Itertools ;
487
488
let target = flags
488
489
. iter ( )
@@ -493,33 +494,35 @@ impl Command {
493
494
// Found it!
494
495
e. sh . set_var ( "MIRI_TEST_TARGET" , target) ;
495
496
} 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 ( ) ) ;
499
500
}
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.
501
502
let have_edition =
502
503
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
+ }
503
507
504
508
// Prepare a sysroot.
505
509
e. build_miri_sysroot ( /* quiet */ true ) ?;
506
510
507
- // Then run the actual command.
511
+ // Then run the actual command. Also add MIRIFLAGS.
508
512
let miri_manifest = path ! ( e. miri_dir / "Cargo.toml" ) ;
509
513
let miri_flags = e. sh . var ( "MIRIFLAGS" ) . unwrap_or_default ( ) ;
510
514
let miri_flags = flagsplit ( & miri_flags) ;
511
515
let toolchain = & e. toolchain ;
512
516
let extra_flags = & e. cargo_extra_flags ;
513
- let edition_flags = ( !have_edition) . then_some ( "--edition=2021" ) ; // keep in sync with `tests/ui.rs`.`
514
517
if dep {
515
518
cmd ! (
516
519
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...}"
518
521
) . quiet ( ) . run ( ) ?;
519
522
} else {
520
523
cmd ! (
521
524
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...}"
523
526
) . quiet ( ) . run ( ) ?;
524
527
}
525
528
Ok ( ( ) )
0 commit comments