diff --git a/src/tools/miri/README.md b/src/tools/miri/README.md index 4483ae242d5..06fe668354a 100644 --- a/src/tools/miri/README.md +++ b/src/tools/miri/README.md @@ -458,8 +458,8 @@ Some native rustc `-Z` flags are also very relevant for Miri: Moreover, Miri recognizes some environment variables: * `MIRI_AUTO_OPS` indicates whether the automatic execution of rustfmt, clippy and toolchain setup - should be skipped. If it is set to any value, they are skipped. This is used for avoiding infinite - recursion in `./miri` and to allow automated IDE actions to avoid the auto ops. + should be skipped. If it is set to `no`, they are skipped. This is used to allow automated IDE + actions to avoid the auto ops. * `MIRI_LOG`, `MIRI_BACKTRACE` control logging and backtrace printing during Miri executions, also [see "Testing the Miri driver" in `CONTRIBUTING.md`][testing-miri]. * `MIRIFLAGS` (recognized by `cargo miri` and the test suite) defines extra diff --git a/src/tools/miri/miri-script/src/commands.rs b/src/tools/miri/miri-script/src/commands.rs index ed78f80c023..ebaef1fd475 100644 --- a/src/tools/miri/miri-script/src/commands.rs +++ b/src/tools/miri/miri-script/src/commands.rs @@ -57,6 +57,10 @@ impl MiriEnv { impl Command { fn auto_actions() -> Result<()> { + if env::var_os("MIRI_AUTO_OPS").is_some_and(|x| x == "no") { + return Ok(()); + } + let miri_dir = miri_dir()?; let auto_everything = path!(miri_dir / ".auto-everything").exists(); let auto_toolchain = auto_everything || path!(miri_dir / ".auto-toolchain").exists(); @@ -78,6 +82,7 @@ impl Command { } pub fn exec(self) -> Result<()> { + // First, and crucially only once, run the auto-actions -- but not for all commands. match &self { Command::Install { .. } | Command::Build { .. } @@ -93,6 +98,7 @@ impl Command { | Command::Bench { .. } | Command::RustcPush { .. } => {} } + // Then run the actual command. match self { Command::Install { flags } => Self::install(flags), Command::Build { flags } => Self::build(flags),