Merge pull request #440 from kbknapp/clippy-update

chore: clippy run
This commit is contained in:
Kevin K 2016-03-08 16:23:48 -05:00
commit 87441b5f76
5 changed files with 23 additions and 23 deletions

View file

@ -17,7 +17,7 @@ vec_map = "~0.4"
ansi_term = { version = "~0.7.2", optional = true }
strsim = { version = "~0.4.0", optional = true }
yaml-rust = { version = "~0.3", optional = true }
clippy = { version = "~0.0.41", optional = true }
clippy = { version = "~0.0.48", optional = true }
[features]
default = ["suggestions", "color"]

View file

@ -372,17 +372,15 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
// required too
let mut found = false;
for p in self.positionals.values().rev() {
if !found {
if p.settings.is_set(ArgSettings::Required) {
found = true;
continue;
}
} else {
assert!(p.settings.is_set(ArgSettings::Required),
if found {
debug_assert!(p.settings.is_set(ArgSettings::Required),
"Found positional argument which is not required with a lower index than a \
required positional argument: {:?} index {}",
p.name,
p.index);
} else if p.settings.is_set(ArgSettings::Required) {
found = true;
continue;
}
}
}
@ -1281,9 +1279,7 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
usage.push_str("USAGE:\n\t");
if let Some(u) = self.meta.usage_str {
usage.push_str(&*u);
} else if !used.is_empty() {
self.smart_usage(&mut usage, used);
} else {
} else if used.is_empty() {
usage.push_str(&*self.meta.usage
.as_ref()
.unwrap_or(self.meta.bin_name
@ -1326,6 +1322,8 @@ impl<'a, 'b> Parser<'a, 'b> where 'a: 'b {
} else if self.is_set(AppSettings::SubcommandRequired) && !self.has_subcommands() {
usage.push_str(" <SUBCOMMAND>");
}
} else {
self.smart_usage(&mut usage, used);
}
usage.shrink_to_fit();

View file

@ -605,10 +605,10 @@ impl Error {
For more information try {}",
Format::Error("error:"),
Format::Warning(&*a),
if !did_you_mean.is_empty() {
format!("{}\n", did_you_mean)
} else {
if did_you_mean.is_empty() {
"\n".to_owned()
} else {
format!("{}\n", did_you_mean)
},
usage,
Format::Good("--help")),

View file

@ -396,6 +396,8 @@
#![cfg_attr(feature = "lints", allow(cyclomatic_complexity))]
// Only while bitflats uses "_first" inside it's macros
#![cfg_attr(feature = "lints", allow(used_underscore_binding))]
// Only while bitflats fails this lint
#![cfg_attr(feature = "lints", allow(if_not_else))]
#[cfg(feature = "suggestions")]
extern crate strsim;

View file

@ -76,7 +76,15 @@ impl<'a> UsageParser<'a> {
self.pos += 1;
self.stop_at(name_end);
let name = &self.usage[self.start..self.pos];
if self.prev != UsageToken::Unknown {
if self.prev == UsageToken::Unknown {
debugln!("setting name: {}", name);
arg.name = name;
if arg.long.is_none() && arg.short.is_none() {
debugln!("explicit name set...");
self.explicit_name_set = true;
self.prev = UsageToken::Name;
}
} else {
debugln!("setting val name: {}", name);
if let Some(ref mut v) = arg.val_names {
let len = v.len();
@ -88,14 +96,6 @@ impl<'a> UsageParser<'a> {
arg.setb(ArgSettings::TakesValue);
}
self.prev = UsageToken::ValName;
} else {
debugln!("setting name: {}", name);
arg.name = name;
if arg.long.is_none() && arg.short.is_none() {
debugln!("explicit name set...");
self.explicit_name_set = true;
self.prev = UsageToken::Name;
}
}
}