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

Commit 4609252

Browse files
authored
Merge pull request rust-lang#3215 from scampi/issue3214
allow to run a rustfmt command from cargo-fmt even when there is no target
2 parents 1cc61cf + a2da636 commit 4609252

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/cargo-fmt/main.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -322,7 +322,8 @@ fn run_rustfmt(
322322
fmt_args: &[String],
323323
verbosity: Verbosity,
324324
) -> Result<i32, io::Error> {
325-
let by_edition = targets
325+
let default_edition = String::from("2015");
326+
let mut by_edition = targets
326327
.iter()
327328
.inspect(|t| {
328329
if verbosity == Verbosity::Verbose {
@@ -334,6 +335,9 @@ fn run_rustfmt(
334335
h.entry(t.0).or_insert_with(Vec::new).push(t.1);
335336
h
336337
});
338+
if by_edition.is_empty() {
339+
by_edition.insert(&default_edition, Vec::new());
340+
}
337341

338342
for (edition, files) in by_edition {
339343
let stdout = if verbosity == Verbosity::Quiet {

0 commit comments

Comments
 (0)