1735: Get rid of extra scopes r=pksunkara a=CreepySkeleton



Co-authored-by: CreepySkeleton <creepy-skeleton@yandex.ru>
This commit is contained in:
bors[bot] 2020-03-09 21:03:59 +00:00 committed by GitHub
commit bc738e12c2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 23 additions and 30 deletions

View file

@ -1408,12 +1408,9 @@ impl<'b> App<'b> {
self._build(); self._build();
} }
{ // do the real parsing
let mut parser = Parser::new(self); let mut parser = Parser::new(self);
parser.get_matches_with(&mut matcher, it)?;
// do the real parsing
parser.get_matches_with(&mut matcher, it)?;
}
let global_arg_vec: Vec<Id> = self let global_arg_vec: Vec<Id> = self
.args .args
@ -1438,13 +1435,12 @@ impl<'b> App<'b> {
self._derive_display_order(); self._derive_display_order();
self._create_help_and_version(); self._create_help_and_version();
// Perform expensive debug assertions // Perform expensive debug assertions
debug_assert!({ #[cfg(debug_assertions)]
for a in self.args.args.iter() { for a in self.args.args.iter() {
self._arg_debug_asserts(a); self._arg_debug_asserts(a);
} }
true
});
let mut pos_counter = 1; let mut pos_counter = 1;
for a in self.args.args.iter_mut() { for a in self.args.args.iter_mut() {

View file

@ -153,22 +153,20 @@ impl<'b> MKeyMap<'b> {
let positional; let positional;
let mut longs: Vec<_>; let mut longs: Vec<_>;
{ let arg = &self.args[index];
let arg = &self.args[index]; short = arg.short.map(KeyType::Short);
short = arg.short.map(KeyType::Short); positional = arg.index.map(KeyType::Position);
positional = arg.index.map(KeyType::Position);
longs = arg longs = arg
.aliases .aliases
.clone() .clone()
.map(|v| { .map(|v| {
v.iter() v.iter()
.map(|(n, _)| KeyType::Long(OsString::from(n))) .map(|(n, _)| KeyType::Long(OsString::from(n)))
.collect() .collect()
}) })
.unwrap_or_default(); .unwrap_or_default();
longs.extend(arg.long.map(|l| KeyType::Long(OsString::from(l)))); longs.extend(arg.long.map(|l| KeyType::Long(OsString::from(l))));
}
if let Some(s) = short { if let Some(s) = short {
self.insert_key(s, index) self.insert_key(s, index)

View file

@ -41,9 +41,8 @@ impl<'b, 'c, 'z> Validator<'b, 'c, 'z> {
self.p.add_defaults(matcher)?; self.p.add_defaults(matcher)?;
if let ParseResult::Opt(a) = needs_val_of { if let ParseResult::Opt(a) = needs_val_of {
debugln!("Validator::validate: needs_val_of={:?}", a); debugln!("Validator::validate: needs_val_of={:?}", a);
{ self.validate_required(matcher)?;
self.validate_required(matcher)?;
}
let o = self.p.app.find(a).expect(INTERNAL_ERROR_MSG); let o = self.p.app.find(a).expect(INTERNAL_ERROR_MSG);
reqs_validated = true; reqs_validated = true;
let should_err = if let Some(v) = matcher.0.args.get(&o.id) { let should_err = if let Some(v) = matcher.0.args.get(&o.id) {