Repository: clap-rs/clap
Pull request #2300 (2021-01-18 18:14:12)

Fix clippy warnings
Fix clippy warnings on nightly tests.


Patch:
diff --git a/clap_derive/src/attrs.rs b/clap_derive/src/attrs.rs
index e570211d..4cd01b8a 100644
--- a/clap_derive/src/attrs.rs
+++ b/clap_derive/src/attrs.rs
@@ -118,7 +118,7 @@ impl Method {
         Method { name, args }
     }
 
-    fn from_lit_or_env(ident: Ident, lit: Option<LitStr>, env_var: &str) -> Option<Self> {
+    fn from_lit_or_env(ident: Ident, lit: Option<LitStr>, env_var: &str) -> Self {
         let mut lit = match lit {
             Some(lit) => lit,
 
@@ -139,7 +139,7 @@ impl Method {
             lit = LitStr::new(&edited, lit.span());
         }
 
-        Some(Method::new(ident, quote!(#lit)))
+        Method::new(ident, quote!(#lit))
     }
 }
 
@@ -372,17 +372,16 @@ impl Attrs {
 
                 About(ident, about) => {
                     let method = Method::from_lit_or_env(ident, about, "CARGO_PKG_DESCRIPTION");
-                    if let Some(m) = method {
-                        self.methods.push(m);
-                    }
+                    self.methods.push(method);
                 }
 
                 Author(ident, author) => {
-                    self.author = Method::from_lit_or_env(ident, author, "CARGO_PKG_AUTHORS");
+                    self.author = Some(Method::from_lit_or_env(ident, author, "CARGO_PKG_AUTHORS"));
                 }
 
                 Version(ident, version) => {
-                    self.version = Method::from_lit_or_env(ident, version, "CARGO_PKG_VERSION");
+                    self.version =
+                        Some(Method::from_lit_or_env(ident, version, "CARGO_PKG_VERSION"));
                 }
 
                 NameLitStr(name, lit) => {
diff --git a/src/parse/matches/arg_matches.rs b/src/parse/matches/arg_matches.rs
index 987e396d..a86cb5d9 100644
--- a/src/parse/matches/arg_matches.rs
+++ b/src/parse/matches/arg_matches.rs
@@ -1015,7 +1015,7 @@ impl<'a> Default for Values<'a> {
         // This is never called because the iterator is empty:
         fn to_str_slice(_: &OsString) -> &str {
             unreachable!()
-        };
+        }
         Values {
             iter: EMPTY[..].iter().map(to_str_slice),
         }
@@ -1075,7 +1075,7 @@ impl Default for OsValues<'_> {
         // This is never called because the iterator is empty:
         fn to_str_slice(_: &OsString) -> &OsStr {
             unreachable!()
-        };
+        }
         OsValues {
             iter: EMPTY[..].iter().map(to_str_slice),
         }


Test patch:
diff --git a/clap_derive/tests/arg_enum.rs b/clap_derive/tests/arg_enum.rs
index 9b3ab65c..ecf8023b 100644
--- a/clap_derive/tests/arg_enum.rs
+++ b/clap_derive/tests/arg_enum.rs
@@ -21,7 +21,7 @@ fn basic() {
     struct Opt {
         #[clap(arg_enum)]
         arg: ArgChoice,
-    };
+    }
 
     assert_eq!(
         Opt {
@@ -51,7 +51,7 @@ fn multi_word_is_renamed_kebab() {
     struct Opt {
         #[clap(arg_enum)]
         arg: ArgChoice,
-    };
+    }
 
     assert_eq!(
         Opt {
@@ -80,7 +80,7 @@ fn variant_with_defined_casing() {
     struct Opt {
         #[clap(arg_enum)]
         arg: ArgChoice,
-    };
+    }
 
     assert_eq!(
         Opt {
@@ -103,7 +103,7 @@ fn casing_is_propogated_from_parent() {
     struct Opt {
         #[clap(arg_enum)]
         arg: ArgChoice,
-    };
+    }
 
     assert_eq!(
         Opt {
@@ -127,7 +127,7 @@ fn casing_propogation_is_overridden() {
     struct Opt {
         #[clap(arg_enum)]
         arg: ArgChoice,
-    };
+    }
 
     assert_eq!(
         Opt {
@@ -150,7 +150,7 @@ fn case_insensitive() {
     struct Opt {
         #[clap(arg_enum, case_insensitive(true))]
         arg: ArgChoice,
-    };
+    }
 
     assert_eq!(
         Opt {
@@ -177,7 +177,7 @@ fn case_insensitive_set_to_false() {
     struct Opt {
         #[clap(arg_enum, case_insensitive(false))]
         arg: ArgChoice,
-    };
+    }
 
     assert_eq!(
         Opt {
@@ -200,7 +200,7 @@ fn alias() {
     struct Opt {
         #[clap(arg_enum, case_insensitive(false))]
         arg: ArgChoice,
-    };
+    }
 
     assert_eq!(
         Opt {
@@ -228,7 +228,7 @@ fn multiple_alias() {
     struct Opt {
         #[clap(arg_enum, case_insensitive(false))]
         arg: ArgChoice,
-    };
+    }
 
     assert_eq!(
         Opt {
@@ -262,7 +262,7 @@ fn option() {
     struct Opt {
         #[clap(arg_enum)]
         arg: Option<ArgChoice>,
-    };
+    }
 
     assert_eq!(Opt { arg: None }, Opt::parse_from(&[""]));
     assert_eq!(
@@ -292,7 +292,7 @@ fn vector() {
     struct Opt {
         #[clap(arg_enum, short, long)]
         arg: Vec<ArgChoice>,
-    };
+    }
 
     assert_eq!(Opt { arg: vec![] }, Opt::parse_from(&[""]));
     assert_eq!(