allow to run a rustfmt command from cargo-fmt even when there is no target

This commit is contained in:
Stéphane Campinas 2018-11-26 20:39:12 +01:00
parent 1cc61cfc2b
commit a2da636ab3
No known key found for this signature in database
GPG key ID: 6D5620D908210133

View file

@ -322,7 +322,8 @@ fn run_rustfmt(
fmt_args: &[String],
verbosity: Verbosity,
) -> Result<i32, io::Error> {
let by_edition = targets
let default_edition = String::from("2015");
let mut by_edition = targets
.iter()
.inspect(|t| {
if verbosity == Verbosity::Verbose {
@ -334,6 +335,9 @@ fn run_rustfmt(
h.entry(t.0).or_insert_with(Vec::new).push(t.1);
h
});
if by_edition.is_empty() {
by_edition.insert(&default_edition, Vec::new());
}
for (edition, files) in by_edition {
let stdout = if verbosity == Verbosity::Quiet {