@@ -65,16 +65,6 @@ fn forward_patched_extern_arg(args: &mut impl Iterator<Item = String>, cmd: &mut
65
65
}
66
66
67
67
pub fn phase_cargo_miri ( mut args : impl Iterator < Item = String > ) {
68
- // Check for version and help flags even when invoked as `cargo-miri`.
69
- if has_arg_flag ( "--help" ) || has_arg_flag ( "-h" ) {
70
- show_help ( ) ;
71
- return ;
72
- }
73
- if has_arg_flag ( "--version" ) || has_arg_flag ( "-V" ) {
74
- show_version ( ) ;
75
- return ;
76
- }
77
-
78
68
// Require a subcommand before any flags.
79
69
// We cannot know which of those flags take arguments and which do not,
80
70
// so we cannot detect subcommands later.
@@ -85,11 +75,36 @@ pub fn phase_cargo_miri(mut args: impl Iterator<Item = String>) {
85
75
"setup" => MiriCommand :: Setup ,
86
76
"test" | "t" | "run" | "r" | "nextest" => MiriCommand :: Forward ( subcommand) ,
87
77
"clean" => MiriCommand :: Clean ,
88
- _ =>
78
+ _ => {
79
+ // Check for version and help flags.
80
+ if has_arg_flag ( "--help" ) || has_arg_flag ( "-h" ) {
81
+ show_help ( ) ;
82
+ return ;
83
+ }
84
+ if has_arg_flag ( "--version" ) || has_arg_flag ( "-V" ) {
85
+ show_version ( ) ;
86
+ return ;
87
+ }
89
88
show_error ! (
90
89
"`cargo miri` supports the following subcommands: `run`, `test`, `nextest`, `clean`, and `setup`."
91
- ) ,
90
+ )
91
+ }
92
92
} ;
93
+ if has_arg_flag ( "--help" ) || has_arg_flag ( "-h" ) {
94
+ match subcommand {
95
+ MiriCommand :: Forward ( verb) => {
96
+ println ! ( "`cargo miri {verb}` supports the same flags as `cargo {verb}`:\n " ) ;
97
+ let mut cmd = cargo ( ) ;
98
+ cmd. arg ( verb) ;
99
+ cmd. arg ( "--help" ) ;
100
+ exec ( cmd) ;
101
+ }
102
+ _ => {
103
+ show_help ( ) ;
104
+ return ;
105
+ }
106
+ }
107
+ }
93
108
let verbose = num_arg_flag ( "-v" ) + num_arg_flag ( "--verbose" ) ;
94
109
let quiet = has_arg_flag ( "-q" ) || has_arg_flag ( "--quiet" ) ;
95
110
0 commit comments