Merge pull request #3144 from otavio/issues-3143

cargo-fmt: Fix splitting of targets across editions
This commit is contained in:
Nick Cameron 2018-10-29 11:22:05 +13:00 committed by GitHub
commit bdd40493ca
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -322,15 +322,18 @@ fn run_rustfmt(
fmt_args: &[String],
verbosity: Verbosity,
) -> Result<i32, io::Error> {
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!();