Skip to content

Commit 08105e8

Browse files
ytmimicalebcartwright
authored andcommitted
Fix issue where cargo fmt --version would not display version info
Fixes 5395 In PR 5239 we switched from using `structopt` to `clap`. It seems that the default behavior for `clap` is to override the `--version` flag, which prevented our custom version display code from running. The fix as outlined in clap-rs/clap#3405 was to set `#[clap(global_setting(AppSettings::NoAutoVersion))]` to prevent clap from setting its own default behavior for the `--version` flag.
1 parent a187091 commit 08105e8

File tree

1 file changed

+2
-1
lines changed

1 file changed

+2
-1
lines changed

src/cargo-fmt/main.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -14,14 +14,15 @@ use std::path::{Path, PathBuf};
1414
use std::process::Command;
1515
use std::str;
1616

17-
use clap::{CommandFactory, Parser};
17+
use clap::{AppSettings, CommandFactory, Parser};
1818

1919
#[path = "test/mod.rs"]
2020
#[cfg(test)]
2121
mod cargo_fmt_tests;
2222

2323
#[derive(Parser)]
2424
#[clap(
25+
global_setting(AppSettings::NoAutoVersion),
2526
bin_name = "cargo fmt",
2627
about = "This utility formats all bin and lib files of \
2728
the current crate using rustfmt."

0 commit comments

Comments
 (0)