Skip to content

Commit 466ddc9

Browse files
committed
Fix using --help, --verbose, etc.
1 parent 71fa794 commit 466ddc9

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

src/cargo-fmt/main.rs

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -142,10 +142,11 @@ fn format_crate(
142142
strategy: &CargoFmtStrategy,
143143
rustfmt_args: Vec<String>,
144144
) -> Result<i32, io::Error> {
145-
let targets = if rustfmt_args
146-
.iter()
147-
.any(|s| ["--print-config", "-h", "--help", "-V", "--version"].contains(&s.as_str()))
148-
{
145+
let targets = if rustfmt_args.iter().any(|s| {
146+
["--print-config", "-h", "--help", "-V", "--version"].contains(&s.as_str())
147+
|| s.starts_with("--help=")
148+
|| s.starts_with("--print-config=")
149+
}) {
149150
BTreeSet::new()
150151
} else {
151152
get_targets(strategy)?
@@ -333,7 +334,7 @@ fn run_rustfmt(
333334
fmt_args: &[String],
334335
verbosity: Verbosity,
335336
) -> Result<i32, io::Error> {
336-
let by_edition = targets
337+
let mut by_edition = targets
337338
.iter()
338339
.inspect(|t| {
339340
if verbosity == Verbosity::Verbose {
@@ -345,6 +346,11 @@ fn run_rustfmt(
345346
h
346347
});
347348

349+
let s = "2018".to_string();
350+
if by_edition.is_empty() {
351+
by_edition.insert(&s, vec![]);
352+
}
353+
348354
let mut status = vec![];
349355
for (edition, files) in by_edition {
350356
let stdout = if verbosity == Verbosity::Quiet {

0 commit comments

Comments
 (0)