diff --git a/src/bin/cargo/cli.rs b/src/bin/cargo/cli.rs index 00e528d80f7..26f75ee8b7f 100644 --- a/src/bin/cargo/cli.rs +++ b/src/bin/cargo/cli.rs @@ -242,11 +242,15 @@ fn expand_aliases( (Some(_), None) => { // Command is built-in and is not conflicting with alias, but contains ignored values. if let Some(mut values) = args.get_many::("") { - config.shell().warn(format!( - "trailing arguments after built-in command `{}` are ignored: `{}`", + return Err(anyhow::format_err!( + "\ +trailing arguments after built-in command `{}` are unsupported: `{}` + +To pass the arguments to the subcommand, remove `--`", cmd, values.join(" "), - ))?; + ) + .into()); } } (None, None) => {} diff --git a/tests/testsuite/cargo_alias_config.rs b/tests/testsuite/cargo_alias_config.rs index 6777aeabf84..7d09557e0ad 100644 --- a/tests/testsuite/cargo_alias_config.rs +++ b/tests/testsuite/cargo_alias_config.rs @@ -324,11 +324,12 @@ fn weird_check() { .build(); p.cargo("-- check --invalid_argument -some-other-argument") + .with_status(101) .with_stderr( "\ -[WARNING] trailing arguments after built-in command `check` are ignored: `--invalid_argument -some-other-argument` -[CHECKING] foo v0.5.0 ([..]) -[FINISHED] dev [unoptimized + debuginfo] target(s) in [..] +[ERROR] trailing arguments after built-in command `check` are unsupported: `--invalid_argument -some-other-argument` + +To pass the arguments to the subcommand, remove `--` ", ) .run();