@@ -43,7 +43,12 @@ pub fn main(config: &mut Config) -> CliResult {
4343 }
4444 } ;
4545
46- if args. value_of ( "unstable-features" ) == Some ( "help" ) {
46+ // Global args need to be extracted before expanding aliases because the
47+ // clap code for extracting a subcommand discards global options
48+ // (appearing before the subcommand).
49+ let ( expanded_args, global_args) = expand_aliases ( config, args, vec ! [ ] ) ?;
50+
51+ if expanded_args. value_of ( "unstable-features" ) == Some ( "help" ) {
4752 let options = CliUnstable :: help ( ) ;
4853 let non_hidden_options: Vec < ( String , String ) > = options
4954 . iter ( )
@@ -95,20 +100,20 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'",
95100 return Ok ( ( ) ) ;
96101 }
97102
98- let is_verbose = args . occurrences_of ( "verbose" ) > 0 ;
99- if args . is_present ( "version" ) {
103+ let is_verbose = expanded_args . occurrences_of ( "verbose" ) > 0 ;
104+ if expanded_args . is_present ( "version" ) {
100105 let version = get_version_string ( is_verbose) ;
101106 drop_print ! ( config, "{}" , version) ;
102107 return Ok ( ( ) ) ;
103108 }
104109
105- if let Some ( code) = args . value_of ( "explain" ) {
110+ if let Some ( code) = expanded_args . value_of ( "explain" ) {
106111 let mut procss = config. load_global_rustc ( None ) ?. process ( ) ;
107112 procss. arg ( "--explain" ) . arg ( code) . exec ( ) ?;
108113 return Ok ( ( ) ) ;
109114 }
110115
111- if args . is_present ( "list" ) {
116+ if expanded_args . is_present ( "list" ) {
112117 drop_println ! ( config, "Installed Commands:" ) ;
113118 for ( name, command) in list_commands ( config) {
114119 let known_external_desc = KNOWN_EXTERNAL_COMMAND_DESCRIPTIONS . get ( name. as_str ( ) ) ;
@@ -140,10 +145,6 @@ Run with 'cargo -Z [FLAG] [SUBCOMMAND]'",
140145 return Ok ( ( ) ) ;
141146 }
142147
143- // Global args need to be extracted before expanding aliases because the
144- // clap code for extracting a subcommand discards global options
145- // (appearing before the subcommand).
146- let ( expanded_args, global_args) = expand_aliases ( config, args, vec ! [ ] ) ?;
147148 let ( cmd, subcommand_args) = match expanded_args. subcommand ( ) {
148149 ( cmd, Some ( args) ) => ( cmd, args) ,
149150 _ => {
0 commit comments