diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs
index 2e22d14993e..d7ef5f062aa 100644
--- a/src/cargo/util/command_prelude.rs
+++ b/src/cargo/util/command_prelude.rs
@@ -375,6 +375,7 @@ pub trait CommandExt: Sized {
fn arg_manifest_path_without_unsupported_path_tip(self) -> Self {
self._arg(
opt("manifest-path", "Path to Cargo.toml")
+ .short('m')
.value_name("PATH")
.help_heading(heading::MANIFEST_OPTIONS)
.add(clap_complete::engine::ArgValueCompleter::new(
diff --git a/tests/testsuite/build.rs b/tests/testsuite/build.rs
index b204d80f681..d28efeace62 100644
--- a/tests/testsuite/build.rs
+++ b/tests/testsuite/build.rs
@@ -293,6 +293,19 @@ For more information, try '--help'.
.run();
}
+#[cargo_test]
+fn cargo_compile_with_manifest_path_shorthand() {
+ let p = project()
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]))
+ .build();
+
+ p.cargo("build -m foo/Cargo.toml")
+ .cwd(p.root().parent().unwrap())
+ .run();
+ assert!(p.bin("foo").is_file());
+}
+
#[cargo_test]
fn chdir_gated() {
let p = project()
diff --git a/tests/testsuite/cargo_add/help/stdout.term.svg b/tests/testsuite/cargo_add/help/stdout.term.svg
index f2c454599ac..6ce6cfd4597 100644
--- a/tests/testsuite/cargo_add/help/stdout.term.svg
+++ b/tests/testsuite/cargo_add/help/stdout.term.svg
@@ -172,7 +172,7 @@
Manifest Options:
- --manifest-path <PATH>
+ -m, --manifest-path <PATH>
Path to Cargo.toml
diff --git a/tests/testsuite/cargo_bench/help/stdout.term.svg b/tests/testsuite/cargo_bench/help/stdout.term.svg
index 7245f6485f0..d916e1f72fd 100644
--- a/tests/testsuite/cargo_bench/help/stdout.term.svg
+++ b/tests/testsuite/cargo_bench/help/stdout.term.svg
@@ -128,7 +128,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_build/help/stdout.term.svg b/tests/testsuite/cargo_build/help/stdout.term.svg
index f64842cf9b6..6f3c21fb789 100644
--- a/tests/testsuite/cargo_build/help/stdout.term.svg
+++ b/tests/testsuite/cargo_build/help/stdout.term.svg
@@ -124,7 +124,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_check/help/stdout.term.svg b/tests/testsuite/cargo_check/help/stdout.term.svg
index 55e49ce8f96..05148571f16 100644
--- a/tests/testsuite/cargo_check/help/stdout.term.svg
+++ b/tests/testsuite/cargo_check/help/stdout.term.svg
@@ -122,7 +122,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_clean/help/stdout.term.svg b/tests/testsuite/cargo_clean/help/stdout.term.svg
index f6c24792fad..1d60aa0010f 100644
--- a/tests/testsuite/cargo_clean/help/stdout.term.svg
+++ b/tests/testsuite/cargo_clean/help/stdout.term.svg
@@ -72,7 +72,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_doc/help/stdout.term.svg b/tests/testsuite/cargo_doc/help/stdout.term.svg
index 0599767ae07..d7c98ca5141 100644
--- a/tests/testsuite/cargo_doc/help/stdout.term.svg
+++ b/tests/testsuite/cargo_doc/help/stdout.term.svg
@@ -116,7 +116,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_fetch/help/stdout.term.svg b/tests/testsuite/cargo_fetch/help/stdout.term.svg
index feeab6268e6..08667f3d144 100644
--- a/tests/testsuite/cargo_fetch/help/stdout.term.svg
+++ b/tests/testsuite/cargo_fetch/help/stdout.term.svg
@@ -54,7 +54,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_fix/help/stdout.term.svg b/tests/testsuite/cargo_fix/help/stdout.term.svg
index cc977ad5d45..0cbf5081add 100644
--- a/tests/testsuite/cargo_fix/help/stdout.term.svg
+++ b/tests/testsuite/cargo_fix/help/stdout.term.svg
@@ -132,7 +132,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_generate_lockfile/help/stdout.term.svg b/tests/testsuite/cargo_generate_lockfile/help/stdout.term.svg
index 9981a5f4dc7..1081a980039 100644
--- a/tests/testsuite/cargo_generate_lockfile/help/stdout.term.svg
+++ b/tests/testsuite/cargo_generate_lockfile/help/stdout.term.svg
@@ -48,7 +48,7 @@
Manifest Options:
- --manifest-path <PATH>
+ -m, --manifest-path <PATH>
Path to Cargo.toml
diff --git a/tests/testsuite/cargo_locate_project/help/stdout.term.svg b/tests/testsuite/cargo_locate_project/help/stdout.term.svg
index 45aed77188a..d390c4a3910 100644
--- a/tests/testsuite/cargo_locate_project/help/stdout.term.svg
+++ b/tests/testsuite/cargo_locate_project/help/stdout.term.svg
@@ -52,7 +52,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_metadata/help/stdout.term.svg b/tests/testsuite/cargo_metadata/help/stdout.term.svg
index 6f878257642..a79c71a1d90 100644
--- a/tests/testsuite/cargo_metadata/help/stdout.term.svg
+++ b/tests/testsuite/cargo_metadata/help/stdout.term.svg
@@ -68,7 +68,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_package/help/stdout.term.svg b/tests/testsuite/cargo_package/help/stdout.term.svg
index 5b8725bfa55..556e414fa95 100644
--- a/tests/testsuite/cargo_package/help/stdout.term.svg
+++ b/tests/testsuite/cargo_package/help/stdout.term.svg
@@ -96,7 +96,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_pkgid/help/stdout.term.svg b/tests/testsuite/cargo_pkgid/help/stdout.term.svg
index 74f0d5ed26e..1ec66e9af4f 100644
--- a/tests/testsuite/cargo_pkgid/help/stdout.term.svg
+++ b/tests/testsuite/cargo_pkgid/help/stdout.term.svg
@@ -60,7 +60,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_publish/help/stdout.term.svg b/tests/testsuite/cargo_publish/help/stdout.term.svg
index 270335282d3..4f694fdeca1 100644
--- a/tests/testsuite/cargo_publish/help/stdout.term.svg
+++ b/tests/testsuite/cargo_publish/help/stdout.term.svg
@@ -90,7 +90,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_read_manifest/help/stdout.term.svg b/tests/testsuite/cargo_read_manifest/help/stdout.term.svg
index 8ce51b39fd7..d79a48a585c 100644
--- a/tests/testsuite/cargo_read_manifest/help/stdout.term.svg
+++ b/tests/testsuite/cargo_read_manifest/help/stdout.term.svg
@@ -52,7 +52,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_remove/help/stdout.term.svg b/tests/testsuite/cargo_remove/help/stdout.term.svg
index a7060069e04..949debd1aef 100644
--- a/tests/testsuite/cargo_remove/help/stdout.term.svg
+++ b/tests/testsuite/cargo_remove/help/stdout.term.svg
@@ -72,7 +72,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_report_sessions/help/stdout.term.svg b/tests/testsuite/cargo_report_sessions/help/stdout.term.svg
index afb9cf36d91..997baef8a51 100644
--- a/tests/testsuite/cargo_report_sessions/help/stdout.term.svg
+++ b/tests/testsuite/cargo_report_sessions/help/stdout.term.svg
@@ -50,7 +50,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_report_timings/help/stdout.term.svg b/tests/testsuite/cargo_report_timings/help/stdout.term.svg
index 00b692de7cd..b3cb603610e 100644
--- a/tests/testsuite/cargo_report_timings/help/stdout.term.svg
+++ b/tests/testsuite/cargo_report_timings/help/stdout.term.svg
@@ -52,7 +52,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_run/help/stdout.term.svg b/tests/testsuite/cargo_run/help/stdout.term.svg
index ef4d7547a49..9f50eb063d9 100644
--- a/tests/testsuite/cargo_run/help/stdout.term.svg
+++ b/tests/testsuite/cargo_run/help/stdout.term.svg
@@ -104,7 +104,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_rustc/help/stdout.term.svg b/tests/testsuite/cargo_rustc/help/stdout.term.svg
index f161b7a8595..001db2cc54d 100644
--- a/tests/testsuite/cargo_rustc/help/stdout.term.svg
+++ b/tests/testsuite/cargo_rustc/help/stdout.term.svg
@@ -126,7 +126,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_rustdoc/help/stdout.term.svg b/tests/testsuite/cargo_rustdoc/help/stdout.term.svg
index cd66b8715b0..750ed3c754c 100644
--- a/tests/testsuite/cargo_rustdoc/help/stdout.term.svg
+++ b/tests/testsuite/cargo_rustdoc/help/stdout.term.svg
@@ -124,7 +124,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_test/help/stdout.term.svg b/tests/testsuite/cargo_test/help/stdout.term.svg
index 83ef2a104c7..19807417e01 100644
--- a/tests/testsuite/cargo_test/help/stdout.term.svg
+++ b/tests/testsuite/cargo_test/help/stdout.term.svg
@@ -134,7 +134,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_tree/help/stdout.term.svg b/tests/testsuite/cargo_tree/help/stdout.term.svg
index 3a9dfdbcf3b..a244777c7f6 100644
--- a/tests/testsuite/cargo_tree/help/stdout.term.svg
+++ b/tests/testsuite/cargo_tree/help/stdout.term.svg
@@ -100,7 +100,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_update/help/stdout.term.svg b/tests/testsuite/cargo_update/help/stdout.term.svg
index fa8208911f9..acd9123199b 100644
--- a/tests/testsuite/cargo_update/help/stdout.term.svg
+++ b/tests/testsuite/cargo_update/help/stdout.term.svg
@@ -64,7 +64,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--ignore-rust-version Ignore `rust-version` specification in packages
diff --git a/tests/testsuite/cargo_vendor/help/stdout.term.svg b/tests/testsuite/cargo_vendor/help/stdout.term.svg
index 3dc423db9e7..a26301282b5 100644
--- a/tests/testsuite/cargo_vendor/help/stdout.term.svg
+++ b/tests/testsuite/cargo_vendor/help/stdout.term.svg
@@ -62,7 +62,7 @@
Manifest Options:
- --manifest-path <PATH> Path to Cargo.toml
+ -m, --manifest-path <PATH> Path to Cargo.toml
--locked Assert that `Cargo.lock` will remain unchanged
diff --git a/tests/testsuite/cargo_verify_project/help/stdout.term.svg b/tests/testsuite/cargo_verify_project/help/stdout.term.svg
index f21961b88da..8f847f05a25 100644
--- a/tests/testsuite/cargo_verify_project/help/stdout.term.svg
+++ b/tests/testsuite/cargo_verify_project/help/stdout.term.svg
@@ -1,7 +1,7 @@