about summary refs log tree commit diff
diff options
context:
space:
mode:
authorGuillaume Gomez <guillaume1.gomez@gmail.com>2024-01-05 16:44:01 +0100
committerGuillaume Gomez <guillaume1.gomez@gmail.com>2024-01-05 16:44:01 +0100
commit9e4e8ef1023d02367a8919f4d13df913f2232cb2 (patch)
tree6a21ad0574cf1e2adcedc1c92b6355fe6058af9a
parentbf5c0d8334adbaa246f2087f4d031da7e3d8bbb8 (diff)
downloadrust-9e4e8ef1023d02367a8919f4d13df913f2232cb2.tar.gz
rust-9e4e8ef1023d02367a8919f4d13df913f2232cb2.zip
Don't emit `struct_field_names` lint if all fields are booleans and don't start with the type's name
-rw-r--r--clippy_lints/src/item_name_repetitions.rs5
1 files changed, 5 insertions, 0 deletions
diff --git a/clippy_lints/src/item_name_repetitions.rs b/clippy_lints/src/item_name_repetitions.rs
index a9f1612ff05..276c1abb60c 100644
--- a/clippy_lints/src/item_name_repetitions.rs
+++ b/clippy_lints/src/item_name_repetitions.rs
@@ -1,6 +1,7 @@
 //! lint on enum variants that are prefixed or suffixed by the same characters
 
 use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_hir};
+use clippy_utils::is_bool;
 use clippy_utils::macros::span_is_local;
 use clippy_utils::source::is_present_in_source;
 use clippy_utils::str_utils::{camel_case_split, count_match_end, count_match_start, to_camel_case, to_snake_case};
@@ -231,6 +232,10 @@ fn check_fields(cx: &LateContext<'_>, threshold: u64, item: &Item<'_>, fields: &
             (false, _) => ("pre", prefix),
             (true, false) => ("post", postfix),
         };
+        if fields.iter().all(|field| is_bool(field.ty)) {
+            // If all fields are booleans, we don't want to emit this lint.
+            return;
+        }
         span_lint_and_help(
             cx,
             STRUCT_FIELD_NAMES,