diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index 25176cb22d18..69d668d46ffe 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -267,6 +267,24 @@ pub trait CommandExt: Sized { } fn arg_manifest_path(self) -> Self { + // We use `--manifest-path` instead of `--path`. + let unsupported_path_arg = { + let value_parser = UnknownArgumentValueParser::suggest_arg("--manifest-path"); + flag("unsupported-path-flag", "") + .long("path") + .value_parser(value_parser) + .hide(true) + }; + self._arg( + opt("manifest-path", "Path to Cargo.toml") + .value_name("PATH") + .help_heading(heading::MANIFEST_OPTIONS), + ) + ._arg(unsupported_path_arg) + } + + // `cargo add` has a `--path` flag to install a crate from a local path. + fn arg_manifest_path_without_unsupported_path_tip(self) -> Self { self._arg( opt("manifest-path", "Path to Cargo.toml") .value_name("PATH") diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs index 5c4c5cbc1d3c..23840ad9a609 100644 --- a/tests/testsuite/build.rs +++ b/tests/testsuite/build.rs @@ -218,6 +218,8 @@ fn cargo_compile_with_wrong_manifest_path_flag() { "\ error: unexpected argument '--path' found + tip: a similar argument exists: '--manifest-path' + Usage: cargo[EXE] build [OPTIONS] For more information, try '--help'.