Skip to content

Commit bdd4049

Browse files
authored
Merge pull request rust-lang#3144 from otavio/issues-3143
cargo-fmt: Fix splitting of targets across editions
2 parents 42780f0 + 12275f2 commit bdd4049

File tree

1 file changed

+7
-3
lines changed

1 file changed

+7
-3
lines changed

src/cargo-fmt/main.rs

+7-3
Original file line numberDiff line numberDiff line change
@@ -322,15 +322,18 @@ fn run_rustfmt(
322322
fmt_args: &[String],
323323
verbosity: Verbosity,
324324
) -> Result<i32, io::Error> {
325-
let by_edition: HashMap<_, _> = targets
325+
let by_edition = targets
326326
.iter()
327327
.inspect(|t| {
328328
if verbosity == Verbosity::Verbose {
329329
println!("[{} ({})] {:?}", t.kind, t.edition, t.path)
330330
}
331331
})
332-
.map(|t| (&t.edition, vec![&t.path]))
333-
.collect();
332+
.map(|t| (&t.edition, &t.path))
333+
.fold(HashMap::new(), |mut h, t| {
334+
h.entry(t.0).or_insert_with(Vec::new).push(t.1);
335+
h
336+
});
334337

335338
for (edition, files) in by_edition {
336339
let stdout = if verbosity == Verbosity::Quiet {
@@ -341,6 +344,7 @@ fn run_rustfmt(
341344

342345
if verbosity == Verbosity::Verbose {
343346
print!("rustfmt");
347+
print!(" --edition {}", edition);
344348
fmt_args.iter().for_each(|f| print!(" {}", f));
345349
files.iter().for_each(|f| print!(" {}", f.display()));
346350
println!();

0 commit comments

Comments
 (0)