diff --git a/src/cargo/util/command_prelude.rs b/src/cargo/util/command_prelude.rs index e11a902a6..bc1d1a6ef 100644 --- a/src/cargo/util/command_prelude.rs +++ b/src/cargo/util/command_prelude.rs @@ -10,6 +10,7 @@ use crate::util::important_paths::find_root_manifest_for_wd; use crate::util::interning::InternedString; use crate::util::is_rustup; use crate::util::restricted_names; +use crate::util::toml::is_embedded; use crate::util::{ print_available_benches, print_available_binaries, print_available_examples, print_available_packages, print_available_tests, @@ -325,7 +326,21 @@ pub trait CommandExt: Sized { self._arg( opt("manifest-path", "Path to Cargo.toml") .value_name("PATH") - .help_heading(heading::MANIFEST_OPTIONS), + .help_heading(heading::MANIFEST_OPTIONS) + .add(clap_complete::engine::ArgValueCompleter::new( + clap_complete::engine::PathCompleter::any().filter(|path: &Path| { + if path.file_name() == Some(OsStr::new("Cargo.toml")) { + return true; + } + if is_embedded(path) { + return true; + } + if path.is_file() && path.extension().is_none() { + return true; + } + false + }), + )), ) }