From a2da636ab340b02d79b95ff02a653199b01e0af2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Campinas?= Date: Mon, 26 Nov 2018 20:39:12 +0100 Subject: [PATCH] allow to run a rustfmt command from cargo-fmt even when there is no target --- src/cargo-fmt/main.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/cargo-fmt/main.rs b/src/cargo-fmt/main.rs index e903c27555a5..b24965658851 100644 --- a/src/cargo-fmt/main.rs +++ b/src/cargo-fmt/main.rs @@ -322,7 +322,8 @@ fn run_rustfmt( fmt_args: &[String], verbosity: Verbosity, ) -> Result { - 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 {