Skip to content

Commit

Permalink
Merge pull request #2077 from clap-rs/no_warnings_v2
Browse files Browse the repository at this point in the history
Eradicate remaining warnings in v2
  • Loading branch information
pksunkara authored Aug 15, 2020
2 parents 33bebed + 7ea1658 commit 0c7da9f
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 10 deletions.
14 changes: 7 additions & 7 deletions src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,10 @@ where
assert!(self.verify_positionals());
let should_err = self.groups.iter().all(|g| {
g.args.iter().all(|arg| {
(self.flags.iter().any(|f| &f.b.name == arg)
self.flags.iter().any(|f| &f.b.name == arg)
|| self.opts.iter().any(|o| &o.b.name == arg)
|| self.positionals.values().any(|p| &p.b.name == arg)
|| self.groups.iter().any(|g| &g.name == arg))
|| self.groups.iter().any(|g| &g.name == arg)
})
});
let g = self.groups.iter().find(|g| {
Expand Down Expand Up @@ -197,7 +197,7 @@ where
);
}
let i = if a.index.is_none() {
(self.positionals.len() + 1)
self.positionals.len() + 1
} else {
a.index.unwrap() as usize
};
Expand Down Expand Up @@ -306,7 +306,7 @@ where
self.implied_settings(&a);
if a.index.is_some() || (a.s.short.is_none() && a.s.long.is_none()) {
let i = if a.index.is_none() {
(self.positionals.len() + 1)
self.positionals.len() + 1
} else {
a.index.unwrap() as usize
};
Expand All @@ -331,7 +331,7 @@ where
self.implied_settings(a);
if a.index.is_some() || (a.s.short.is_none() && a.s.long.is_none()) {
let i = if a.index.is_none() {
(self.positionals.len() + 1)
self.positionals.len() + 1
} else {
a.index.unwrap() as usize
};
Expand Down Expand Up @@ -839,15 +839,15 @@ where
.iter()
.find(|o| o.b.name == name)
.expect(INTERNAL_ERROR_MSG);
(o.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings)
o.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings
}
ParseResult::Pos(name) => {
let p = self
.positionals
.values()
.find(|p| p.b.name == name)
.expect(INTERNAL_ERROR_MSG);
(p.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings)
p.is_set(ArgSettings::AllowLeadingHyphen) || app_wide_settings
}
ParseResult::ValuesDone => return true,
_ => false,
Expand Down
2 changes: 1 addition & 1 deletion src/app/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -361,7 +361,7 @@ impl<'a, 'b, 'z> Validator<'a, 'b, 'z> {
a,
num,
if a.is_set(ArgSettings::Multiple) {
(ma.vals.len() % num as usize)
ma.vals.len() % num as usize
} else {
ma.vals.len()
},
Expand Down
2 changes: 2 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,6 +540,8 @@
#![cfg_attr(feature = "lints", allow(cyclomatic_complexity))]
#![cfg_attr(feature = "lints", allow(doc_markdown))]
#![cfg_attr(feature = "lints", allow(explicit_iter_loop))]
// Due to our "MSRV for 2.x will remain unchanged" policy, we can't fix these warnings
#![allow(bare_trait_objects, deprecated)]

#[cfg(all(feature = "color", not(target_os = "windows")))]
extern crate ansi_term;
Expand Down
7 changes: 5 additions & 2 deletions src/osstringext.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,9 +112,12 @@ impl OsStrExt2 for OsStr {
// `clap.exe --arg=[invalid]`. Note that this entire module is
// replaced in Clap 3.x, so this workaround is specific to the 2.x
// branch.
return windows_osstr_starts_with(self, s);
windows_osstr_starts_with(self, s)
}
#[cfg(not(target_os = "windows"))]
{
self.as_bytes().starts_with(s)
}
self.as_bytes().starts_with(s)
}

fn contains_byte(&self, byte: u8) -> bool {
Expand Down

0 comments on commit 0c7da9f

Please sign in to comment.