Skip to content

Commit 9e4e8ef

Browse files
Don't emit struct_field_names lint if all fields are booleans and don't start with the type's name
1 parent bf5c0d8 commit 9e4e8ef

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

clippy_lints/src/item_name_repetitions.rs

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
//! lint on enum variants that are prefixed or suffixed by the same characters
22
33
use clippy_utils::diagnostics::{span_lint, span_lint_and_help, span_lint_hir};
4+
use clippy_utils::is_bool;
45
use clippy_utils::macros::span_is_local;
56
use clippy_utils::source::is_present_in_source;
67
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: &
231232
(false, _) => ("pre", prefix),
232233
(true, false) => ("post", postfix),
233234
};
235+
if fields.iter().all(|field| is_bool(field.ty)) {
236+
// If all fields are booleans, we don't want to emit this lint.
237+
return;
238+
}
234239
span_lint_and_help(
235240
cx,
236241
STRUCT_FIELD_NAMES,

0 commit comments

Comments
 (0)