Repository: kbknapp/clap-rs
Pull request #1224 (2018-03-21 02:58:46)

Clippy fixes
This makes some further progress towards being cleaner under clippy.

<!-- Reviewable:start -->
---
This change is [<img src="https://reviewable.io/review_button.svg" height="34" align="absmiddle" alt="Reviewable"/>](https://reviewable.io/reviews/kbknapp/clap-rs/1224)
<!-- Reviewable:end -->



Patch:
diff --git a/src/app/validator.rs b/src/app/validator.rs
index 448a8fc7..6c297f6d 100644
--- a/src/app/validator.rs
+++ b/src/app/validator.rs
@@ -158,9 +158,9 @@ impl<'a, 'b, 'z> Validator<'a, 'b, 'z> {
 
     fn build_err(&self, name: &str, matcher: &ArgMatcher) -> ClapResult<()> {
         debugln!("build_err!: name={}", name);
-        let mut c_with = find_from!(self.0, &name, blacklist, &matcher);
+        let mut c_with = find_from!(self.0, &name, blacklist, matcher);
         c_with = c_with.or(
-        self.0.find_any_arg(&name).map_or(None, |aa| aa.blacklist())
+        self.0.find_any_arg(name).map_or(None, |aa| aa.blacklist())
             .map_or(None,
                     |bl| bl.iter().find(|arg| matcher.contains(arg)))
             .map_or(None, |an| self.0.find_any_arg(an))
diff --git a/src/args/arg.rs b/src/args/arg.rs
index 4faba969..7829f29c 100644
--- a/src/args/arg.rs
+++ b/src/args/arg.rs
@@ -1296,9 +1296,9 @@ impl<'a, 'b> Arg<'a, 'b> {
     /// ```
     pub fn overrides_with(mut self, name: &'a str) -> Self {
         if let Some(ref mut vec) = self.b.overrides {
-            vec.push(name.as_ref());
+            vec.push(name);
         } else {
-            self.b.overrides = Some(vec![name.as_ref()]);
+            self.b.overrides = Some(vec![name]);
         }
         self
     }
diff --git a/src/completions/powershell.rs b/src/completions/powershell.rs
index b06d4d19..9fc77c72 100644
--- a/src/completions/powershell.rs
+++ b/src/completions/powershell.rs
@@ -62,7 +62,7 @@ fn escape_string(string: &str) -> String { string.replace("'", "''") }
 
 fn get_tooltip<T : ToString>(help: Option<&str>, data: T) -> String {
     match help {
-        Some(help) => escape_string(&help),
+        Some(help) => escape_string(help),
         _ => data.to_string()
     }
 }
diff --git a/src/errors.rs b/src/errors.rs
index c6367bf4..35ac58bd 100644
--- a/src/errors.rs
+++ b/src/errors.rs
@@ -405,7 +405,7 @@ impl Error {
     pub fn write_to<W: Write>(&self, w: &mut W) -> io::Result<()> { write!(w, "{}", self.message) }
 
     #[doc(hidden)]
-    pub fn argument_conflict<'a, 'b, O, U>(
+    pub fn argument_conflict<O, U>(
         arg: &AnyArg,
         other: Option<O>,
         usage: U,
@@ -444,7 +444,7 @@ impl Error {
     }
 
     #[doc(hidden)]
-    pub fn empty_value<'a, 'b, U>(arg: &AnyArg, usage: U, color: ColorWhen) -> Self
+    pub fn empty_value<U>(arg: &AnyArg, usage: U, color: ColorWhen) -> Self
     where
         U: Display,
     {
@@ -469,7 +469,7 @@ impl Error {
     }
 
     #[doc(hidden)]
-    pub fn invalid_value<'a, 'b, B, G, U>(
+    pub fn invalid_value<B, G, U>(
         bad_val: B,
         good_vals: &[G],
         arg: &AnyArg,
@@ -658,7 +658,7 @@ impl Error {
     }
 
     #[doc(hidden)]
-    pub fn too_many_values<'a, 'b, V, U>(val: V, arg: &AnyArg, usage: U, color: ColorWhen) -> Self
+    pub fn too_many_values<V, U>(val: V, arg: &AnyArg, usage: U, color: ColorWhen) -> Self
     where
         V: AsRef<str> + Display + ToOwned,
         U: Display,
@@ -686,7 +686,7 @@ impl Error {
     }
 
     #[doc(hidden)]
-    pub fn too_few_values<'a, 'b, U>(
+    pub fn too_few_values<U>(
         arg: &AnyArg,
         min_vals: u64,
         curr_vals: usize,
@@ -720,7 +720,7 @@ impl Error {
     }
 
     #[doc(hidden)]
-    pub fn value_validation<'a, 'b>(arg: Option<&AnyArg>, err: String, color: ColorWhen) -> Self
+    pub fn value_validation(arg: Option<&AnyArg>, err: String, color: ColorWhen) -> Self
     {
         let c = Colorizer::new(ColorizerOption {
             use_stderr: true,
@@ -749,7 +749,7 @@ impl Error {
     }
 
     #[doc(hidden)]
-    pub fn wrong_number_of_values<'a, 'b, S, U>(
+    pub fn wrong_number_of_values<S, U>(
         arg: &AnyArg,
         num_vals: u64,
         curr_vals: usize,
@@ -785,7 +785,7 @@ impl Error {
     }
 
     #[doc(hidden)]
-    pub fn unexpected_multiple_usage<'a, 'b, U>(arg: &AnyArg, usage: U, color: ColorWhen) -> Self
+    pub fn unexpected_multiple_usage<U>(arg: &AnyArg, usage: U, color: ColorWhen) -> Self
     where
         U: Display,
     {


Test patch:
diff --git a/clap-test.rs b/clap-test.rs
index 964f9060..7d57ac4f 100644
--- a/clap-test.rs
+++ b/clap-test.rs
@@ -19,7 +19,7 @@ mod test {
         let right = re.replace_all(&*rs, "");
         let b = left == right;
         if !b {
-            println!("");
+            println!();
             println!("--> left");
             println!("{}", left);
             println!("--> right");
diff --git a/tests/arg_aliases.rs b/tests/arg_aliases.rs
index 9b4f0bf2..77bcd17d 100644
--- a/tests/arg_aliases.rs
+++ b/tests/arg_aliases.rs
@@ -57,7 +57,7 @@ fn multiple_aliases_of_option() {
             .long("aliases")
             .takes_value(true)
             .help("multiple aliases")
-            .aliases(&vec![
+            .aliases(&[
                 "alias1",
                 "alias2",
                 "alias3"
@@ -151,7 +151,7 @@ fn alias_on_a_subcommand_option() {
                 .help("testing testing")))
         .arg(Arg::with_name("other")
             .long("other")
-            .aliases(&vec!["o1", "o2", "o3"]))
+            .aliases(&["o1", "o2", "o3"]))
         .get_matches_from(vec![
             "test", "some", "--opt", "awesome"
         ]);
diff --git a/tests/completions.rs b/tests/completions.rs
index 09f0fb22..48705ceb 100644
--- a/tests/completions.rs
+++ b/tests/completions.rs
@@ -604,7 +604,7 @@ fn compare(left: &str, right: &str) -> bool {
     let b = left == right;
     if !b {
         let re = Regex::new(" ").unwrap();
-        println!("");
+        println!();
         println!("--> left");
         // println!("{}", left);
         println!("{}", re.replace_all(left, "\u{2022}"));
diff --git a/tests/propagate_globals.rs b/tests/propagate_globals.rs
index a52fcfc6..ee77ce0a 100644
--- a/tests/propagate_globals.rs
+++ b/tests/propagate_globals.rs
@@ -28,7 +28,7 @@ mod tests {
     }
 
     fn get_matches(app: App<'static, 'static>, argv: &'static str) -> ArgMatches<'static> {
-        app.get_matches_from(argv.split(" ").collect::<Vec<_>>())
+        app.get_matches_from(argv.split(' ').collect::<Vec<_>>())
     }
 
     fn get_outer_matches<'a>(m: &'a ArgMatches<'static>) -> &'a ArgMatches<'static> {
diff --git a/tests/tests.rs b/tests/tests.rs
index 84ecf9d8..0ad825a5 100644
--- a/tests/tests.rs
+++ b/tests/tests.rs
@@ -275,7 +275,7 @@ fn create_app() {
 #[test]
 fn add_multiple_arg() {
     let _ = App::new("test")
-                .args(&mut [
+                .args(&[
                     Arg::with_name("test").short("s"),
                     Arg::with_name("test2").short("l")])
                 .get_matches_from(vec![""]);