From 7ea1658d33533a84a229e9816f59fc75046a69cb Mon Sep 17 00:00:00 2001 From: CreepySkeleton Date: Sat, 15 Aug 2020 01:54:20 +0300 Subject: [PATCH] Eradicate remaining warnings --- src/app/parser.rs | 14 +++++++------- src/app/validator.rs | 2 +- src/lib.rs | 2 ++ src/osstringext.rs | 7 +++++-- 4 files changed, 15 insertions(+), 10 deletions(-) diff --git a/src/app/parser.rs b/src/app/parser.rs index c05602e83d2..83bca079c84 100644 --- a/src/app/parser.rs +++ b/src/app/parser.rs @@ -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| { @@ -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 }; @@ -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 }; @@ -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 }; @@ -839,7 +839,7 @@ 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 @@ -847,7 +847,7 @@ where .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, diff --git a/src/app/validator.rs b/src/app/validator.rs index 862f0bbde4e..8b0b0017e45 100644 --- a/src/app/validator.rs +++ b/src/app/validator.rs @@ -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() }, diff --git a/src/lib.rs b/src/lib.rs index 17e2697be04..855c182e6a9 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -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; diff --git a/src/osstringext.rs b/src/osstringext.rs index ee0de302e2a..e07f7fd0465 100644 --- a/src/osstringext.rs +++ b/src/osstringext.rs @@ -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 {