Skip to content

Commit e6bbbac

Browse files
committed
Avoid infinite recursion for auto-fmt and auto-clippy
1 parent b473d95 commit e6bbbac

File tree

1 file changed

+16
-9
lines changed

1 file changed

+16
-9
lines changed

miri-script/src/commands.rs

+16-9
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ impl MiriEnv {
5858
impl Command {
5959
fn auto_actions() -> Result<()> {
6060
let miri_dir = miri_dir()?;
61-
let auto_everything = path!(miri_dir / ".auto_everything").exists();
61+
let auto_everything = path!(miri_dir / ".auto-everything").exists();
6262
let auto_toolchain = auto_everything || path!(miri_dir / ".auto-toolchain").exists();
6363
let auto_fmt = auto_everything || path!(miri_dir / ".auto-fmt").exists();
6464
let auto_clippy = auto_everything || path!(miri_dir / ".auto-clippy").exists();
@@ -78,6 +78,21 @@ impl Command {
7878
}
7979

8080
pub fn exec(self) -> Result<()> {
81+
match &self {
82+
Command::Install { .. }
83+
| Command::Build { .. }
84+
| Command::Check { .. }
85+
| Command::Test { .. }
86+
| Command::Run { .. }
87+
| Command::Fmt { .. }
88+
| Command::Clippy { .. }
89+
| Command::Cargo { .. } => Self::auto_actions()?,
90+
| Command::ManySeeds { .. }
91+
| Command::Toolchain { .. }
92+
| Command::RustcPull { .. }
93+
| Command::Bench { .. }
94+
| Command::RustcPush { .. } => {}
95+
}
8196
match self {
8297
Command::Install { flags } => Self::install(flags),
8398
Command::Build { flags } => Self::build(flags),
@@ -328,31 +343,27 @@ impl Command {
328343
}
329344

330345
fn install(flags: Vec<OsString>) -> Result<()> {
331-
Self::auto_actions()?;
332346
let e = MiriEnv::new()?;
333347
e.install_to_sysroot(e.miri_dir.clone(), &flags)?;
334348
e.install_to_sysroot(path!(e.miri_dir / "cargo-miri"), &flags)?;
335349
Ok(())
336350
}
337351

338352
fn build(flags: Vec<OsString>) -> Result<()> {
339-
Self::auto_actions()?;
340353
let e = MiriEnv::new()?;
341354
e.build(path!(e.miri_dir / "Cargo.toml"), &flags, /* quiet */ false)?;
342355
e.build(path!(e.miri_dir / "cargo-miri" / "Cargo.toml"), &flags, /* quiet */ false)?;
343356
Ok(())
344357
}
345358

346359
fn check(flags: Vec<OsString>) -> Result<()> {
347-
Self::auto_actions()?;
348360
let e = MiriEnv::new()?;
349361
e.check(path!(e.miri_dir / "Cargo.toml"), &flags)?;
350362
e.check(path!(e.miri_dir / "cargo-miri" / "Cargo.toml"), &flags)?;
351363
Ok(())
352364
}
353365

354366
fn clippy(flags: Vec<OsString>) -> Result<()> {
355-
Self::auto_actions()?;
356367
let e = MiriEnv::new()?;
357368
e.clippy(path!(e.miri_dir / "Cargo.toml"), &flags)?;
358369
e.clippy(path!(e.miri_dir / "cargo-miri" / "Cargo.toml"), &flags)?;
@@ -361,7 +372,6 @@ impl Command {
361372
}
362373

363374
fn cargo(flags: Vec<OsString>) -> Result<()> {
364-
Self::auto_actions()?;
365375
let e = MiriEnv::new()?;
366376
let toolchain = &e.toolchain;
367377
// We carefully kept the working dir intact, so this will run cargo *on the workspace in the
@@ -371,7 +381,6 @@ impl Command {
371381
}
372382

373383
fn test(bless: bool, flags: Vec<OsString>) -> Result<()> {
374-
Self::auto_actions()?;
375384
let mut e = MiriEnv::new()?;
376385
// Prepare a sysroot.
377386
e.build_miri_sysroot(/* quiet */ false)?;
@@ -386,7 +395,6 @@ impl Command {
386395
}
387396

388397
fn run(dep: bool, flags: Vec<OsString>) -> Result<()> {
389-
Self::auto_actions()?;
390398
let mut e = MiriEnv::new()?;
391399
// Scan for "--target" to overwrite the "MIRI_TEST_TARGET" env var so
392400
// that we set the MIRI_SYSROOT up the right way.
@@ -424,7 +432,6 @@ impl Command {
424432
}
425433

426434
fn fmt(flags: Vec<OsString>) -> Result<()> {
427-
Self::auto_actions()?;
428435
let e = MiriEnv::new()?;
429436
let toolchain = &e.toolchain;
430437
let config_path = path!(e.miri_dir / "rustfmt.toml");

0 commit comments

Comments
 (0)