Skip to content

Commit

Permalink
fix(derive): Don't enit warnings
Browse files Browse the repository at this point in the history
We missed covering `Args` warnings when using struct variants.

Fixes #3245
  • Loading branch information
epage committed Jan 3, 2022
1 parent b0cb205 commit 6b9ae54
Show file tree
Hide file tree
Showing 4 changed files with 6 additions and 6 deletions.
2 changes: 1 addition & 1 deletion clap_derive/src/derives/args.rs
Expand Up @@ -117,7 +117,7 @@ pub fn gen_from_arg_matches_for_struct(
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

quote! {
#[allow(dead_code, unreachable_code, unused_variables)]
#[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
#[allow(
clippy::style,
clippy::complexity,
Expand Down
4 changes: 2 additions & 2 deletions clap_derive/src/derives/into_app.rs
Expand Up @@ -43,7 +43,7 @@ pub fn gen_for_struct(
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

let tokens = quote! {
#[allow(dead_code, unreachable_code, unused_variables)]
#[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
#[allow(
clippy::style,
clippy::complexity,
Expand Down Expand Up @@ -88,7 +88,7 @@ pub fn gen_for_enum(enum_name: &Ident, generics: &Generics, attrs: &[Attribute])
let (impl_generics, ty_generics, where_clause) = generics.split_for_impl();

quote! {
#[allow(dead_code, unreachable_code, unused_variables)]
#[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
#[allow(
clippy::style,
clippy::complexity,
Expand Down
2 changes: 1 addition & 1 deletion clap_derive/src/derives/subcommand.rs
Expand Up @@ -61,7 +61,7 @@ pub fn gen_for_enum(
quote! {
#from_arg_matches

#[allow(dead_code, unreachable_code, unused_variables)]
#[allow(dead_code, unreachable_code, unused_variables, unused_braces)]
#[allow(
clippy::style,
clippy::complexity,
Expand Down
4 changes: 2 additions & 2 deletions tests/derive/deny_warnings.rs
Expand Up @@ -24,7 +24,7 @@ fn try_str(s: &str) -> Result<String, std::convert::Infallible> {
fn warning_never_struct() {
#[derive(Parser, Debug, PartialEq)]
struct Opt {
#[clap(parse(try_from_str = try_str))]
#[clap(parse(try_from_str = try_str), default_value_t)]
s: String,
}
assert_eq!(
Expand All @@ -40,7 +40,7 @@ fn warning_never_enum() {
#[derive(Parser, Debug, PartialEq)]
enum Opt {
Foo {
#[clap(parse(try_from_str = try_str))]
#[clap(parse(try_from_str = try_str), default_value_t)]
s: String,
},
}
Expand Down

0 comments on commit 6b9ae54

Please sign in to comment.