From 0824c5d7e126b58d1b246bfce6b5ab8405213a60 Mon Sep 17 00:00:00 2001 From: jonboh Date: Sun, 24 Sep 2023 18:20:18 +0200 Subject: [PATCH] rename enum_variants threshold and add ui-toml test just for struct, as the enum ice is being fixed in a different branch --- clippy_lints/src/lib.rs | 4 ++-- clippy_lints/src/utils/conf.rs | 10 +++------- .../item_name_repetitions_threshold0/clippy.toml | 1 + .../item_name_repetitions.rs | 3 +++ tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr | 6 ++---- 5 files changed, 11 insertions(+), 13 deletions(-) create mode 100644 tests/ui-toml/item_name_repetitions_threshold0/clippy.toml create mode 100644 tests/ui-toml/item_name_repetitions_threshold0/item_name_repetitions.rs diff --git a/clippy_lints/src/lib.rs b/clippy_lints/src/lib.rs index ab8acd313d58..712869eaf873 100644 --- a/clippy_lints/src/lib.rs +++ b/clippy_lints/src/lib.rs @@ -846,11 +846,11 @@ pub fn register_plugins(store: &mut rustc_lint::LintStore, sess: &Session, conf: literal_representation_threshold, )) }); - let enum_variant_name_threshold = conf.enum_variant_name_threshold; + let item_name_threshold = conf.item_name_threshold; let allow_private_module_inception = conf.allow_private_module_inception; store.register_late_pass(move |_| { Box::new(item_name_repetitions::ItemNameRepetitions::new( - enum_variant_name_threshold, + item_name_threshold, avoid_breaking_exported_api, allow_private_module_inception, )) diff --git a/clippy_lints/src/utils/conf.rs b/clippy_lints/src/utils/conf.rs index 94ae6b5c1bea..3b71c39f5874 100644 --- a/clippy_lints/src/utils/conf.rs +++ b/clippy_lints/src/utils/conf.rs @@ -356,14 +356,10 @@ define_Conf! { /// /// The maximum size of objects (in bytes) that will be linted. Larger objects are ok on the heap (too_large_for_stack: u64 = 200), - /// Lint: ENUM_VARIANT_NAMES. + /// Lint: ENUM_VARIANT_NAMES, STRUCT_FIELD_NAMES /// - /// The minimum number of enum variants for the lints about variant names to trigger - (enum_variant_name_threshold: u64 = 3), - /// Lint: STRUCT_FIELD_NAMES. - /// - /// The minimum number of struct fields for the lints about field names to trigger - (struct_fields_name_threshold: u64 = 3), + /// The minimum number of enum variants or sruct fields for the lints about variant and field names to trigger + (item_name_threshold: u64 = 3), /// Lint: LARGE_ENUM_VARIANT. /// /// The maximum size of an enum's variant to avoid box suggestion diff --git a/tests/ui-toml/item_name_repetitions_threshold0/clippy.toml b/tests/ui-toml/item_name_repetitions_threshold0/clippy.toml new file mode 100644 index 000000000000..7de0b1a788ab --- /dev/null +++ b/tests/ui-toml/item_name_repetitions_threshold0/clippy.toml @@ -0,0 +1 @@ +item-name-threshold = 0 diff --git a/tests/ui-toml/item_name_repetitions_threshold0/item_name_repetitions.rs b/tests/ui-toml/item_name_repetitions_threshold0/item_name_repetitions.rs new file mode 100644 index 000000000000..6c6185903003 --- /dev/null +++ b/tests/ui-toml/item_name_repetitions_threshold0/item_name_repetitions.rs @@ -0,0 +1,3 @@ +struct Data {} + +fn main() {} diff --git a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr index 700348809f42..760f1b06a5e4 100644 --- a/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr +++ b/tests/ui-toml/toml_unknown_key/conf_unknown_key.stderr @@ -31,11 +31,11 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect enable-raw-pointer-heuristic-for-send enforce-iter-loop-reborrow enforced-import-renames - enum-variant-name-threshold enum-variant-size-threshold excessive-nesting-threshold future-size-threshold ignore-interior-mutability + item-name-threshold large-error-threshold literal-representation-threshold matches-for-let-else @@ -53,7 +53,6 @@ error: error reading Clippy's configuration file: unknown field `foobar`, expect single-char-binding-names-threshold stack-size-threshold standard-macro-braces - struct-fields-name-threshold suppress-restriction-lint-in-const third-party too-large-for-stack @@ -105,11 +104,11 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect enable-raw-pointer-heuristic-for-send enforce-iter-loop-reborrow enforced-import-renames - enum-variant-name-threshold enum-variant-size-threshold excessive-nesting-threshold future-size-threshold ignore-interior-mutability + item-name-threshold large-error-threshold literal-representation-threshold matches-for-let-else @@ -127,7 +126,6 @@ error: error reading Clippy's configuration file: unknown field `barfoo`, expect single-char-binding-names-threshold stack-size-threshold standard-macro-braces - struct-fields-name-threshold suppress-restriction-lint-in-const third-party too-large-for-stack