Disallow some restriction lints (#3754)

This commit is contained in:
Charlie Marsh 2023-03-26 19:20:20 -04:00 committed by GitHub
parent 2326335f5c
commit 31fff4b10e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 11 additions and 7 deletions

View file

@ -26,4 +26,11 @@ rustflags = [
"-Wclippy::print_stdout", "-Wclippy::print_stdout",
"-Wclippy::print_stderr", "-Wclippy::print_stderr",
"-Wclippy::dbg_macro", "-Wclippy::dbg_macro",
"-Wclippy::empty_drop",
"-Wclippy::empty_structs_with_brackets",
"-Wclippy::exit",
"-Wclippy::get_unwrap",
"-Wclippy::rc_buffer",
"-Wclippy::rc_mutex",
"-Wclippy::rest_pat_in_fully_bound_structs",
] ]

View file

@ -56,7 +56,6 @@ mod deferred;
type AnnotationContext = (bool, bool); type AnnotationContext = (bool, bool);
#[allow(clippy::struct_excessive_bools)]
pub struct Checker<'a> { pub struct Checker<'a> {
// Settings, static metadata, etc. // Settings, static metadata, etc.
pub path: &'a Path, pub path: &'a Path,
@ -3582,7 +3581,7 @@ where
} else { } else {
// Ex) DefaultNamedArg(type="bool", name="some_prop_name") // Ex) DefaultNamedArg(type="bool", name="some_prop_name")
for keyword in keywords { for keyword in keywords {
let KeywordData { value, arg, .. } = &keyword.node; let KeywordData { value, arg } = &keyword.node;
if arg.as_ref().map_or(false, |arg| arg == "type") { if arg.as_ref().map_or(false, |arg| arg == "type") {
visit_type_definition!(self, value); visit_type_definition!(self, value);
} else { } else {

View file

@ -73,7 +73,7 @@ impl AlwaysAutofixableViolation for CompareWithTuple {
} }
fn autofix_title(&self) -> String { fn autofix_title(&self) -> String {
let CompareWithTuple { replacement, .. } = self; let CompareWithTuple { replacement } = self;
format!("Replace with `{replacement}`") format!("Replace with `{replacement}`")
} }
} }

View file

@ -31,7 +31,7 @@ impl Violation for YodaConditions {
} }
fn autofix_title_formatter(&self) -> Option<fn(&Self) -> String> { fn autofix_title_formatter(&self) -> Option<fn(&Self) -> String> {
let YodaConditions { suggestion, .. } = self; let YodaConditions { suggestion } = self;
if suggestion.is_some() { if suggestion.is_some() {
Some(|YodaConditions { suggestion }| { Some(|YodaConditions { suggestion }| {
let suggestion = suggestion.as_ref().unwrap(); let suggestion = suggestion.as_ref().unwrap();

View file

@ -172,7 +172,7 @@ fn is_valid_constant(formats: &[CFormatStrOrBytes<String>], value: &Expr) -> boo
if formats.len() != 1 { if formats.len() != 1 {
return true; return true;
} }
let format = formats.get(0).unwrap(); let format = formats[0];
equivalent(format, value) equivalent(format, value)
} }

View file

@ -82,7 +82,6 @@ fn handle_option_group(field: &Field) -> syn::Result<proc_macro2::TokenStream> {
ident: type_ident, ident: type_ident,
arguments: arguments:
PathArguments::AngleBracketed(AngleBracketedGenericArguments { args, .. }), PathArguments::AngleBracketed(AngleBracketedGenericArguments { args, .. }),
..
}) if type_ident == "Option" => { }) if type_ident == "Option" => {
let path = &args[0]; let path = &args[0];
let kebab_name = LitStr::new(&ident.to_string().replace('_', "-"), ident.span()); let kebab_name = LitStr::new(&ident.to_string().replace('_', "-"), ident.span());
@ -142,7 +141,6 @@ fn handle_option(
default, default,
value_type, value_type,
example, example,
..
} = attr.parse_args::<FieldAttributes>()?; } = attr.parse_args::<FieldAttributes>()?;
let kebab_name = LitStr::new(&ident.to_string().replace('_', "-"), ident.span()); let kebab_name = LitStr::new(&ident.to_string().replace('_', "-"), ident.span());