Skip to content

Commit

Permalink
Fix linting errors from rustc 1.14.0
Browse files Browse the repository at this point in the history
The new version of rustc 1.14.0-nightly (144af3e97 2016-10-02) has new
linting warnings/errors. This commit fixes them.

Signed-off-by: Salim Afiune <afiune@chef.io>
  • Loading branch information
Salim Afiune committed Oct 4, 2016
1 parent f8b4c92 commit 771c4c7
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 31 deletions.
22 changes: 11 additions & 11 deletions src/app/help.rs
Original file line number Diff line number Diff line change
Expand Up @@ -212,8 +212,8 @@ impl<'a> Help<'a> {
}
}
let mut first = true;
for (_, btm) in ord_m.into_iter() {
for (_, arg) in btm.into_iter() {
for (_, btm) in ord_m {
for arg in btm.values() {
if !first {
try!(self.writer.write(b"\n"));
} else {
Expand Down Expand Up @@ -380,11 +380,11 @@ impl<'a> Help<'a> {
help.push_str(h);
&*help
};
if help.contains("\n") {
if let Some(part) = help.split("\n").next() {
if help.contains('\n') {
if let Some(part) = help.split('\n').next() {
try!(write!(self.writer, "{}", part));
}
for part in help.split("\n").skip(1) {
for part in help.split('\n').skip(1) {
try!(write!(self.writer, "\n{}", part));
}
} else {
Expand Down Expand Up @@ -464,11 +464,11 @@ impl<'a> Help<'a> {
help.push_str(&*spec_vals);
&*help
};
if help.contains("\n") {
if let Some(part) = help.split("\n").next() {
if help.contains('\n') {
if let Some(part) = help.split('\n').next() {
try!(write!(self.writer, "{}", part));
}
for part in help.split("\n").skip(1) {
for part in help.split('\n').skip(1) {
try!(write!(self.writer, "\n"));
if nlh || force_next_line {
try!(write!(self.writer, "{}{}{}", TAB, TAB, TAB));
Expand Down Expand Up @@ -616,14 +616,14 @@ impl<'a> Help<'a> {
}

let mut first = true;
for (_, btm) in ord_m.into_iter() {
for (_, sc) in btm.into_iter() {
for (_, btm) in ord_m {
for sc in btm.values() {
if !first {
try!(self.writer.write(b"\n"));
} else {
first = false;
}
try!(self.write_arg(&sc, longest));
try!(self.write_arg(sc, longest));
}
}
Ok(())
Expand Down
2 changes: 1 addition & 1 deletion src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -928,7 +928,7 @@ impl<'a, 'b> App<'a, 'b> {
pub fn subcommands<I>(mut self, subcmds: I) -> Self
where I: IntoIterator<Item = App<'a, 'b>>
{
for subcmd in subcmds.into_iter() {
for subcmd in subcmds {
self.p.add_subcommand(subcmd);
}
self
Expand Down
10 changes: 5 additions & 5 deletions src/app/parser.rs
Original file line number Diff line number Diff line change
Expand Up @@ -355,13 +355,13 @@ impl<'a, 'b> Parser<'a, 'b>
grps.dedup();
let mut args_in_groups = vec![];
for g in &grps {
for a in self.arg_names_in_group(g).into_iter() {
for a in self.arg_names_in_group(g) {
args_in_groups.push(a);
}
}

let mut pmap = BTreeMap::new();
for p in c_pos.into_iter() {
for p in c_pos {
if matcher.is_some() && matcher.as_ref().unwrap().contains(p) {
continue;
}
Expand All @@ -382,7 +382,7 @@ impl<'a, 'b> Parser<'a, 'b>
}
macro_rules! write_arg {
($i:expr, $m:ident, $v:ident, $r:ident, $aig:ident) => {
for f in $v.into_iter() {
for f in $v {
if $m.is_some() && $m.as_ref().unwrap().contains(f) || $aig.contains(&f) {
continue;
}
Expand All @@ -393,13 +393,13 @@ impl<'a, 'b> Parser<'a, 'b>
write_arg!(self.flags.iter(), matcher, c_flags, ret_val, args_in_groups);
write_arg!(self.opts.iter(), matcher, c_opt, ret_val, args_in_groups);
let mut g_vec = vec![];
for g in grps.into_iter() {
for g in grps {
let g_string = self.args_in_group(g)
.join("|");
g_vec.push(format!("<{}>", &g_string[..g_string.len()]));
}
g_vec.dedup();
for g in g_vec.into_iter() {
for g in g_vec {
ret_val.push_back(g);
}

Expand Down
2 changes: 1 addition & 1 deletion src/suggestions.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ pub fn did_you_mean<'a, T, I>(v: &str, possible_values: I) -> Option<&'a str>
{

let mut candidate: Option<(f64, &str)> = None;
for pv in possible_values.into_iter() {
for pv in possible_values {
let confidence = strsim::jaro_winkler(v, pv.as_ref());
if confidence > 0.8 &&
(candidate.is_none() || (candidate.as_ref().unwrap().0 < confidence)) {
Expand Down
18 changes: 5 additions & 13 deletions tests/arg_aliases.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,12 +12,10 @@ USAGE:
test [FLAGS] [OPTIONS]
FLAGS:
-f, --flag
flag with aliases [aliases: v_flg, flag2, flg3]
-f, --flag [aliases: v_flg, flag2, flg3]
OPTIONS:
-o, --opt <opt>
help for option with alias [aliases: visible]";
-o, --opt <opt> [aliases: visible]";

static SC_INVISIBLE_ALIAS_HELP: &'static str = "test
Some help
Expand All @@ -26,10 +24,10 @@ USAGE:
test [FLAGS] [OPTIONS]
FLAGS:
-f, --flag flag with aliases
-f, --flag
OPTIONS:
-o, --opt <opt> help for option with alias";
-o, --opt <opt> ";

#[test]
fn single_alias_of_option() {
Expand Down Expand Up @@ -169,13 +167,9 @@ fn invisible_arg_aliases_help_output() {
.arg(Arg::with_name("opt")
.long("opt")
.short("o")
.help("help for option with alias")
.takes_value(true)
.aliases(&["invisible", "als1", "more"]))
.arg(Arg::with_name("flg")
.long("flag")
.short("f")
.help("flag with aliases")
.arg(Arg::from_usage("-f, --flag")
.aliases(&["invisible", "flg1", "anyway"])));
test::check_subcommand_help(app, "test", SC_INVISIBLE_ALIAS_HELP);
}
Expand All @@ -189,14 +183,12 @@ fn visible_arg_aliases_help_output() {
.arg(Arg::with_name("opt")
.long("opt")
.short("o")
.help("help for option with alias")
.takes_value(true)
.alias("invisible")
.visible_alias("visible"))
.arg(Arg::with_name("flg")
.long("flag")
.short("f")
.help("flag with aliases")
.visible_aliases(&["v_flg", "flag2", "flg3"])));
test::check_subcommand_help(app, "test", SC_VISIBLE_ALIAS_HELP);
}

0 comments on commit 771c4c7

Please sign in to comment.