@@ -76,6 +76,38 @@ fn dependent_alias() {
76
76
. run ( ) ;
77
77
}
78
78
79
+ #[ cargo_test]
80
+ fn alias_shadowing_external_subcommand ( ) {
81
+ let echo = echo_subcommand ( ) ;
82
+ let p = project ( )
83
+ . file ( "Cargo.toml" , & basic_bin_manifest ( "foo" ) )
84
+ . file ( "src/main.rs" , "fn main() {}" )
85
+ . file (
86
+ ".cargo/config" ,
87
+ r#"
88
+ [alias]
89
+ echo = "build"
90
+ "# ,
91
+ )
92
+ . build ( ) ;
93
+
94
+ let mut paths: Vec < _ > = env:: split_paths ( & env:: var_os ( "PATH" ) . unwrap_or_default ( ) ) . collect ( ) ;
95
+ paths. push ( echo. target_debug_dir ( ) ) ;
96
+ let path = env:: join_paths ( paths) . unwrap ( ) ;
97
+
98
+ p. cargo ( "echo" )
99
+ . env ( "PATH" , & path)
100
+ . with_stderr ( "\
101
+ [WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]`
102
+ This was previously accepted but is being phased out; it will become a hard error in a future release.
103
+ For more information, see issue #10049 <https://github.com/rust-lang/cargo/issues/10049>.
104
+ [COMPILING] foo v0.5.0 [..]
105
+ [FINISHED] dev [unoptimized + debuginfo] target(s) in [..]
106
+ " ,
107
+ )
108
+ . run ( ) ;
109
+ }
110
+
79
111
#[ cargo_test]
80
112
fn default_args_alias ( ) {
81
113
let echo = echo_subcommand ( ) ;
@@ -100,14 +132,24 @@ fn default_args_alias() {
100
132
p. cargo ( "echo" )
101
133
. env ( "PATH" , & path)
102
134
. with_status ( 101 )
103
- . with_stderr ( "error: alias echo has unresolvable recursive definition: echo -> echo" )
135
+ . with_stderr ( "\
136
+ [WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]`
137
+ This was previously accepted but is being phased out; it will become a hard error in a future release.
138
+ For more information, see issue #10049 <https://github.com/rust-lang/cargo/issues/10049>.
139
+ error: alias echo has unresolvable recursive definition: echo -> echo
140
+ " ,
141
+ )
104
142
. run ( ) ;
105
143
106
144
p. cargo ( "test-1" )
107
145
. env ( "PATH" , & path)
108
146
. with_status ( 101 )
109
- . with_stderr (
110
- "error: alias test-1 has unresolvable recursive definition: test-1 -> echo -> echo" ,
147
+ . with_stderr ( "\
148
+ [WARNING] user-defined alias `echo` is shadowing an external subcommand found at: `[ROOT]/cargo-echo/target/debug/cargo-echo[EXE]`
149
+ This was previously accepted but is being phased out; it will become a hard error in a future release.
150
+ For more information, see issue #10049 <https://github.com/rust-lang/cargo/issues/10049>.
151
+ error: alias test-1 has unresolvable recursive definition: test-1 -> echo -> echo
152
+ " ,
111
153
)
112
154
. run ( ) ;
113
155
0 commit comments