@@ -4,8 +4,8 @@ use clap::{AppSettings, Arg, ArgMatches};
44
55use cargo:: { self , CliResult , Config } ;
66
7+ use super :: commands:: { self , BuiltinExec } ;
78use super :: list_commands;
8- use super :: commands;
99use command_prelude:: * ;
1010
1111pub fn main ( config : & mut Config ) -> CliResult {
@@ -107,26 +107,34 @@ fn expand_aliases(
107107 commands:: builtin_exec ( cmd) ,
108108 super :: aliased_command ( config, cmd) ?,
109109 ) {
110- ( None , Some ( mut alias) ) => {
111- alias. extend (
110+ (
111+ Some ( BuiltinExec {
112+ alias_for : None , ..
113+ } ) ,
114+ Some ( _) ,
115+ ) => {
116+ // User alias conflicts with a built-in subcommand
117+ config. shell ( ) . warn ( format ! (
118+ "user-defined alias `{}` is ignored, because it is shadowed by a built-in command" ,
119+ cmd,
120+ ) ) ?;
121+ }
122+ ( _, Some ( mut user_alias) ) => {
123+ // User alias takes precedence over built-in aliases
124+ user_alias. extend (
112125 args. values_of ( "" )
113126 . unwrap_or_default ( )
114127 . map ( |s| s. to_string ( ) ) ,
115128 ) ;
116129 let args = cli ( )
117130 . setting ( AppSettings :: NoBinaryName )
118- . get_matches_from_safe ( alias ) ?;
131+ . get_matches_from_safe ( user_alias ) ?;
119132 return expand_aliases ( config, args) ;
120133 }
121- ( Some ( _) , Some ( _) ) => {
122- config. shell ( ) . warn ( format ! (
123- "alias `{}` is ignored, because it is shadowed by a built in command" ,
124- cmd
125- ) ) ?;
126- }
127134 ( _, None ) => { }
128135 }
129136 } ;
137+
130138 Ok ( args)
131139}
132140
@@ -152,11 +160,12 @@ fn execute_subcommand(config: &mut Config, args: &ArgMatches) -> CliResult {
152160 args. is_present ( "frozen" ) ,
153161 args. is_present ( "locked" ) ,
154162 arg_target_dir,
155- & args. values_of_lossy ( "unstable-features" )
163+ & args
164+ . values_of_lossy ( "unstable-features" )
156165 . unwrap_or_default ( ) ,
157166 ) ?;
158167
159- if let Some ( exec) = commands:: builtin_exec ( cmd) {
168+ if let Some ( BuiltinExec { exec, .. } ) = commands:: builtin_exec ( cmd) {
160169 return exec ( config, subcommand_args) ;
161170 }
162171
0 commit comments