summaryrefslogtreecommitdiffstats
path: root/vendor/clap_builder/src/builder/debug_asserts.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-30 03:57:31 +0000
commitdc0db358abe19481e475e10c32149b53370f1a1c (patch)
treeab8ce99c4b255ce46f99ef402c27916055b899ee /vendor/clap_builder/src/builder/debug_asserts.rs
parentReleasing progress-linux version 1.71.1+dfsg1-2~progress7.99u1. (diff)
downloadrustc-dc0db358abe19481e475e10c32149b53370f1a1c.tar.xz
rustc-dc0db358abe19481e475e10c32149b53370f1a1c.zip
Merging upstream version 1.72.1+dfsg1.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/clap_builder/src/builder/debug_asserts.rs')
-rw-r--r--vendor/clap_builder/src/builder/debug_asserts.rs30
1 files changed, 26 insertions, 4 deletions
diff --git a/vendor/clap_builder/src/builder/debug_asserts.rs b/vendor/clap_builder/src/builder/debug_asserts.rs
index 7a7fd6ae1..ef970cdaa 100644
--- a/vendor/clap_builder/src/builder/debug_asserts.rs
+++ b/vendor/clap_builder/src/builder/debug_asserts.rs
@@ -300,6 +300,28 @@ pub(crate) fn assert_app(cmd: &Command) {
arg
);
}
+
+ for arg in &group.requires {
+ // Args listed inside groups should exist
+ assert!(
+ cmd.id_exists(arg),
+ "Command {}: Argument group '{}' requires non-existent '{}' id",
+ cmd.get_name(),
+ group.get_id(),
+ arg
+ );
+ }
+
+ for arg in &group.conflicts {
+ // Args listed inside groups should exist
+ assert!(
+ cmd.id_exists(arg),
+ "Command {}: Argument group '{}' conflicts with non-existent '{}' id",
+ cmd.get_name(),
+ group.get_id(),
+ arg
+ );
+ }
}
// Conflicts between flags and subcommands
@@ -460,7 +482,7 @@ fn assert_app_flags(cmd: &Command) {
)+
if !s.is_empty() {
- panic!("{}", s)
+ panic!("{s}")
}
}
};
@@ -564,9 +586,8 @@ fn _verify_positionals(cmd: &Command) -> bool {
|| last.is_last_set();
assert!(
ok,
- "When using a positional argument with `.num_args(1..)` that is *not the \
- last* positional argument, the last positional argument (i.e. the one \
- with the highest index) *must* have .required(true) or .last(true) set."
+ "Positional argument `{last}` *must* have `required(true)` or `last(true)` set \
+ because a prior positional argument (`{second_to_last}`) has `num_args(1..)`"
);
// We make sure if the second to last is Multiple the last is ArgSettings::Last
@@ -582,6 +603,7 @@ fn _verify_positionals(cmd: &Command) -> bool {
.get_positionals()
.filter(|p| {
p.is_multiple_values_set()
+ && p.get_value_terminator().is_none()
&& !p.get_num_args().expect(INTERNAL_ERROR_MSG).is_fixed()
})
.count();