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

View file

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

View file

@ -41,9 +41,8 @@ impl<'b, 'c, 'z> Validator<'b, 'c, 'z> {
self.p.add_defaults(matcher)?;
if let ParseResult::Opt(a) = needs_val_of {
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);
reqs_validated = true;
let should_err = if let Some(v) = matcher.0.args.get(&o.id) {