From: Seiichi Uchida Date: Mon, 4 Dec 2017 23:01:29 +0000 (+0900) Subject: Do not pass files as arguments to rustfmt when dumping the default config X-Git-Url: https://git.lizzy.rs/?a=commitdiff_plain;h=65c90dc08c7b9565a1acf3292c1ddeb71876bcd2;p=rust.git Do not pass files as arguments to rustfmt when dumping the default config --- diff --git a/src/bin/cargo-fmt.rs b/src/bin/cargo-fmt.rs index e6a86e04b9e..e04d772ba0e 100644 --- a/src/bin/cargo-fmt.rs +++ b/src/bin/cargo-fmt.rs @@ -134,7 +134,12 @@ fn format_crate( verbosity: Verbosity, strategy: &CargoFmtStrategy, ) -> Result { - let targets = get_targets(strategy)?; + let rustfmt_args = get_fmt_args(); + let targets = if rustfmt_args.iter().any(|s| s == "--dump-default-config") { + HashSet::new() + } else { + get_targets(strategy)? + }; // Currently only bin and lib files get formatted let files: Vec<_> = targets @@ -147,7 +152,7 @@ fn format_crate( .map(|t| t.path) .collect(); - format_files(&files, &get_fmt_args(), verbosity) + format_files(&files, &rustfmt_args, verbosity) } fn get_fmt_args() -> Vec {