File tree Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Expand file tree Collapse file tree 2 files changed +19
-3
lines changed Original file line number Diff line number Diff line change @@ -261,6 +261,18 @@ fn expand_aliases(
261
261
}
262
262
( None , None ) => { }
263
263
( _, Some ( mut alias) ) => {
264
+ // Check if this alias is shadowing an external subcommand
265
+ // (binary of the form `cargo-<subcommand>`)
266
+ // Currently this is only a warning, but after a transition period this will become
267
+ // a hard error.
268
+ if let Some ( path) = super :: find_external_subcommand ( config, cmd) {
269
+ config. shell ( ) . warn ( format ! (
270
+ "user-defined alias `{}` is shadowing an external subcommand found at: `{}`" ,
271
+ cmd,
272
+ path. display( ) ,
273
+ ) ) ?;
274
+ }
275
+
264
276
alias. extend (
265
277
args. values_of ( "" )
266
278
. unwrap_or_default ( )
Original file line number Diff line number Diff line change @@ -147,12 +147,16 @@ fn list_commands(config: &Config) -> BTreeMap<String, CommandInfo> {
147
147
commands
148
148
}
149
149
150
- fn execute_external_subcommand ( config : & Config , cmd : & str , args : & [ & str ] ) -> CliResult {
150
+ fn find_external_subcommand ( config : & Config , cmd : & str ) -> Option < PathBuf > {
151
151
let command_exe = format ! ( "cargo-{}{}" , cmd, env:: consts:: EXE_SUFFIX ) ;
152
- let path = search_directories ( config)
152
+ search_directories ( config)
153
153
. iter ( )
154
154
. map ( |dir| dir. join ( & command_exe) )
155
- . find ( |file| is_executable ( file) ) ;
155
+ . find ( |file| is_executable ( file) )
156
+ }
157
+
158
+ fn execute_external_subcommand ( config : & Config , cmd : & str , args : & [ & str ] ) -> CliResult {
159
+ let path = find_external_subcommand ( config, cmd) ;
156
160
let command = match path {
157
161
Some ( command) => command,
158
162
None => {
You can’t perform that action at this time.
0 commit comments