diff options
| author | kyoto7250 <50972773+kyoto7250@users.noreply.github.com> | 2022-06-22 07:59:14 +0900 |
|---|---|---|
| committer | kyoto7250 <50972773+kyoto7250@users.noreply.github.com> | 2022-06-22 08:32:54 +0900 |
| commit | ab645bb08177723bf926a6ee2724b5b653fb5d4e (patch) | |
| tree | 6bec5a3dd3de2d1c53ee2a3b5001a71d80df2220 /clippy_lints | |
| parent | 93c6f9ebed65eb4d77a5cf1ccf670cef3b1fca9e (diff) | |
| download | rust-ab645bb08177723bf926a6ee2724b5b653fb5d4e.tar.gz rust-ab645bb08177723bf926a6ee2724b5b653fb5d4e.zip | |
enum_variant_names should ignore when all prefixes are _
Diffstat (limited to 'clippy_lints')
| -rw-r--r-- | clippy_lints/src/enum_variants.rs | 7 |
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; |
