Skip to content

Commit 65c90dc

Browse files
committed
Do not pass files as arguments to rustfmt when dumping the default config
1 parent 24f1f69 commit 65c90dc

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

src/bin/cargo-fmt.rs

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,12 @@ fn format_crate(
134134
verbosity: Verbosity,
135135
strategy: &CargoFmtStrategy,
136136
) -> Result<ExitStatus, io::Error> {
137-
let targets = get_targets(strategy)?;
137+
let rustfmt_args = get_fmt_args();
138+
let targets = if rustfmt_args.iter().any(|s| s == "--dump-default-config") {
139+
HashSet::new()
140+
} else {
141+
get_targets(strategy)?
142+
};
138143

139144
// Currently only bin and lib files get formatted
140145
let files: Vec<_> = targets
@@ -147,7 +152,7 @@ fn format_crate(
147152
.map(|t| t.path)
148153
.collect();
149154

150-
format_files(&files, &get_fmt_args(), verbosity)
155+
format_files(&files, &rustfmt_args, verbosity)
151156
}
152157

153158
fn get_fmt_args() -> Vec<String> {

0 commit comments

Comments
 (0)