From 3efca8a59604de5cfdb7f4723f49af119f421ec8 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Sat, 27 Oct 2018 11:49:48 -0300 Subject: [PATCH 1/2] cargo-fmt: Add --edition when printing the command By mistake, it was forgotten to print out the edition in use when printing the rustcmd command. Fix it. Signed-off-by: Otavio Salvador --- src/cargo-fmt/main.rs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/cargo-fmt/main.rs b/src/cargo-fmt/main.rs index 45d002518286..84b52aed9432 100644 --- a/src/cargo-fmt/main.rs +++ b/src/cargo-fmt/main.rs @@ -341,6 +341,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!(); From 12275f2e6a44d4f466aa38a65d120c0469814ff2 Mon Sep 17 00:00:00 2001 From: Otavio Salvador Date: Sat, 27 Oct 2018 11:55:41 -0300 Subject: [PATCH 2/2] cargo-fmt: Fix splitting of targets across editions When I reworked the code, it ended not generating the complete list of need targets. Fix it. Fixes: #3143. Signed-off-by: Otavio Salvador --- src/cargo-fmt/main.rs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/cargo-fmt/main.rs b/src/cargo-fmt/main.rs index 84b52aed9432..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 {