diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 62e46eb1a..4d47a8e6b 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -306,7 +306,16 @@ For more information, see issue #10049 ." + ))?; + } } let mut alias = alias @@ -411,7 +420,18 @@ fn execute_subcommand(config: &mut Config, cmd: &str, subcommand_args: &ArgMatch .map(OsString::as_os_str), ); if commands::run::is_manifest_command(cmd) { - commands::run::exec_manifest_command(config, cmd, &ext_args) + let ext_path = super::find_external_subcommand(config, cmd); + if !config.cli_unstable().script && ext_path.is_some() { + config.shell().warn(format_args!( + "\ +external subcommand `{cmd}` has the appearance of a manfiest-command +This was previously accepted but will be phased out when `-Zscript` is stabilized. +For more information, see issue #12207 .", + ))?; + super::execute_external_subcommand(config, cmd, &ext_args) + } else { + commands::run::exec_manifest_command(config, cmd, &ext_args) + } } else { super::execute_external_subcommand(config, cmd, &ext_args) } diff --git a/tests/testsuite/script.rs b/tests/testsuite/script.rs index b4b1933ef..169e08278 100644 --- a/tests/testsuite/script.rs +++ b/tests/testsuite/script.rs @@ -100,7 +100,7 @@ note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace #[cargo_test] #[cfg(unix)] -fn manifest_precedence_over_plugins_stable() { +fn warn_when_plugin_masks_manifest_on_stable() { let p = cargo_test_support::project() .file("echo.rs", ECHO_SCRIPT) .executable(std::path::Path::new("path-test").join("cargo-echo.rs"), "") @@ -113,11 +113,12 @@ fn manifest_precedence_over_plugins_stable() { p.cargo("echo.rs") .arg("--help") // An arg that, if processed by cargo, will cause problems .env("PATH", &path) - .with_status(101) .with_stdout("") .with_stderr( "\ -error: running `echo.rs` requires `-Zscript` +warning: external subcommand `echo.rs` has the appearance of a manfiest-command +This was previously accepted but will be phased out when `-Zscript` is stabilized. +For more information, see issue #12207 . ", ) .run();