diff --git a/src/cargo-fmt/main.rs b/src/cargo-fmt/main.rs index 45d002518286..e903c27555a5 100644 --- a/src/cargo-fmt/main.rs +++ b/src/cargo-fmt/main.rs @@ -322,15 +322,18 @@ fn run_rustfmt( fmt_args: &[String], verbosity: Verbosity, ) -> Result { - let by_edition: HashMap<_, _> = targets + let by_edition = targets .iter() .inspect(|t| { if verbosity == Verbosity::Verbose { println!("[{} ({})] {:?}", t.kind, t.edition, t.path) } }) - .map(|t| (&t.edition, vec![&t.path])) - .collect(); + .map(|t| (&t.edition, &t.path)) + .fold(HashMap::new(), |mut h, t| { + h.entry(t.0).or_insert_with(Vec::new).push(t.1); + h + }); for (edition, files) in by_edition { let stdout = if verbosity == Verbosity::Quiet { @@ -341,6 +344,7 @@ fn run_rustfmt( if verbosity == Verbosity::Verbose { print!("rustfmt"); + print!(" --edition {}", edition); fmt_args.iter().for_each(|f| print!(" {}", f)); files.iter().for_each(|f| print!(" {}", f.display())); println!();