Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 5f1f5aa

Browse files
committed
Make sure that we run rustfmt against every edition
1 parent 288d7db commit 5f1f5aa

File tree

1 file changed

+8
-10
lines changed

1 file changed

+8
-10
lines changed

src/cargo-fmt/main.rs

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -311,8 +311,7 @@ fn run_rustfmt(
311311
fmt_args: &[String],
312312
verbosity: Verbosity,
313313
) -> Result<i32, io::Error> {
314-
let default_edition = String::from("2015");
315-
let mut by_edition = targets
314+
let by_edition = targets
316315
.iter()
317316
.inspect(|t| {
318317
if verbosity == Verbosity::Verbose {
@@ -324,10 +323,8 @@ fn run_rustfmt(
324323
h.entry(t.0).or_insert_with(Vec::new).push(t.1);
325324
h
326325
});
327-
if by_edition.is_empty() {
328-
by_edition.insert(&default_edition, Vec::new());
329-
}
330326

327+
let mut status = vec![];
331328
for (edition, files) in by_edition {
332329
let stdout = if verbosity == Verbosity::Quiet {
333330
std::process::Stdio::null()
@@ -357,13 +354,14 @@ fn run_rustfmt(
357354
_ => e,
358355
})?;
359356

360-
let status = command.wait()?;
361-
if !status.success() {
362-
return Ok(status.code().unwrap_or(FAILURE));
363-
}
357+
status.push(command.wait()?);
364358
}
365359

366-
Ok(SUCCESS)
360+
Ok(status
361+
.iter()
362+
.filter_map(|s| if s.success() { None } else { s.code() })
363+
.next()
364+
.unwrap_or(SUCCESS))
367365
}
368366

369367
fn get_cargo_metadata(manifest_path: Option<&Path>) -> Result<cargo_metadata::Metadata, io::Error> {

0 commit comments

Comments
 (0)