Skip to content

Commit 3c041c4

Browse files
committed
Auto merge of rust-lang#3421 - RalfJung:remove-remove-var, r=RalfJung
avoid mutating the global environment `remove_var` is just as bad as `set_var`, let's not do that.
2 parents 9f11ed7 + a8fb4a0 commit 3c041c4

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/tools/miri/cargo-miri/src/phases.rs

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -301,11 +301,6 @@ pub fn phase_rustc(mut args: impl Iterator<Item = String>, phase: RustcPhase) {
301301
}
302302
}
303303

304-
// phase_cargo_miri set `MIRI_BE_RUSTC` for when build scripts directly invoke the driver;
305-
// however, if we get called back by cargo here, we'll carefully compute the right flags
306-
// ourselves, so we first un-do what the earlier phase did.
307-
env::remove_var("MIRI_BE_RUSTC");
308-
309304
let verbose = std::env::var("MIRI_VERBOSE")
310305
.map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer"));
311306
let target_crate = is_target_crate();
@@ -489,11 +484,6 @@ pub enum RunnerPhase {
489484
}
490485

491486
pub fn phase_runner(mut binary_args: impl Iterator<Item = String>, phase: RunnerPhase) {
492-
// phase_cargo_miri set `MIRI_BE_RUSTC` for when build scripts directly invoke the driver;
493-
// however, if we get called back by cargo here, we'll carefully compute the right flags
494-
// ourselves, so we first un-do what the earlier phase did.
495-
env::remove_var("MIRI_BE_RUSTC");
496-
497487
let verbose = std::env::var("MIRI_VERBOSE")
498488
.map_or(0, |verbose| verbose.parse().expect("verbosity flag must be an integer"));
499489

src/tools/miri/cargo-miri/src/util.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,12 @@ pub fn find_miri() -> PathBuf {
101101
}
102102

103103
pub fn miri() -> Command {
104-
Command::new(find_miri())
104+
let mut cmd = Command::new(find_miri());
105+
// We never want to inherit this from the environment.
106+
// However, this is sometimes set in the environment to work around build scripts that don't
107+
// honor RUSTC_WRAPPER. So remove it again in case it is set.
108+
cmd.env_remove("MIRI_BE_RUSTC");
109+
cmd
105110
}
106111

107112
pub fn miri_for_host() -> Command {

0 commit comments

Comments
 (0)