about summary refs log tree commit diff
path: root/clippy_lints/src/enum_variants.rs
diff options
context:
space:
mode:
authorkyoto7250 <50972773+kyoto7250@users.noreply.github.com>2022-06-22 07:59:14 +0900
committerkyoto7250 <50972773+kyoto7250@users.noreply.github.com>2022-06-22 08:32:54 +0900
commitab645bb08177723bf926a6ee2724b5b653fb5d4e (patch)
tree6bec5a3dd3de2d1c53ee2a3b5001a71d80df2220 /clippy_lints/src/enum_variants.rs
parent93c6f9ebed65eb4d77a5cf1ccf670cef3b1fca9e (diff)
downloadrust-ab645bb08177723bf926a6ee2724b5b653fb5d4e.tar.gz
rust-ab645bb08177723bf926a6ee2724b5b653fb5d4e.zip
enum_variant_names should ignore when all prefixes are _
Diffstat (limited to 'clippy_lints/src/enum_variants.rs')
-rw-r--r--clippy_lints/src/enum_variants.rs7
1 files changed, 6 insertions, 1 deletions
diff --git a/clippy_lints/src/enum_variants.rs b/clippy_lints/src/enum_variants.rs
index 23b75104570..517e11b4e6b 100644
--- a/clippy_lints/src/enum_variants.rs
+++ b/clippy_lints/src/enum_variants.rs
@@ -190,7 +190,7 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n
             .map(|e| *e.0)
             .collect();
     }
-    let (what, value) = match (pre.is_empty(), post.is_empty()) {
+    let (what, value) = match (have_no_extra_prefix(&pre), post.is_empty()) {
         (true, true) => return,
         (false, _) => ("pre", pre.join("")),
         (true, false) => {
@@ -213,6 +213,11 @@ fn check_variant(cx: &LateContext<'_>, threshold: u64, def: &EnumDef<'_>, item_n
 }
 
 #[must_use]
+fn have_no_extra_prefix(prefixes: &Vec<&str>) -> bool {
+    prefixes.is_empty() || prefixes.join("") == "_"
+}
+
+#[must_use]
 fn to_camel_case(item_name: &str) -> String {
     let mut s = String::new();
     let mut up = true;