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

Commit 12275f2

Browse files
committed
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: rust-lang#3143. Signed-off-by: Otavio Salvador <[email protected]>
1 parent 3efca8a commit 12275f2

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

src/cargo-fmt/main.rs

Lines changed: 6 additions & 3 deletions
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 {

0 commit comments

Comments
 (0)