Skip to content

Commit 99cd324

Browse files
committed
Auto merge of #3221 - RalfJung:edition, r=RalfJung
./miri run: default to edition 2021 Fixes #2999
2 parents 7360d81 + ff4b901 commit 99cd324

File tree

2 files changed

+13
-4
lines changed

2 files changed

+13
-4
lines changed

miri-script/src/commands.rs

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -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(())

tests/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ fn test_config(target: &str, path: &str, mode: Mode, with_dependencies: bool) ->
9191
mode,
9292
program,
9393
out_dir: PathBuf::from(std::env::var_os("CARGO_TARGET_DIR").unwrap()).join("ui"),
94-
edition: Some("2021".into()),
94+
edition: Some("2021".into()), // keep in sync with `./miri run`
9595
threads: std::env::var("MIRI_TEST_THREADS")
9696
.ok()
9797
.map(|threads| NonZeroUsize::new(threads.parse().unwrap()).unwrap()),

0 commit comments

Comments
 (0)