Rename clippy_utils::camal_case to clippy_utils::str_utils

This commit is contained in:
xFrednet 2021-10-24 17:42:13 +02:00
parent ba0cfc7deb
commit 1b91d986ea
3 changed files with 7 additions and 7 deletions

View File

@ -1,6 +1,6 @@
//! lint on enum variants that are prefixed or suffixed by the same characters //! lint on enum variants that are prefixed or suffixed by the same characters
use clippy_utils::camel_case; use clippy_utils::str_utils;
use clippy_utils::diagnostics::{span_lint, span_lint_and_help}; use clippy_utils::diagnostics::{span_lint, span_lint_and_help};
use clippy_utils::source::is_present_in_source; use clippy_utils::source::is_present_in_source;
use rustc_hir::{EnumDef, Item, ItemKind}; use rustc_hir::{EnumDef, Item, ItemKind};
@ -171,14 +171,14 @@ fn check_variant(
} }
} }
let first = &def.variants[0].ident.name.as_str(); let first = &def.variants[0].ident.name.as_str();
let mut pre = &first[..camel_case::until(&*first)]; let mut pre = &first[..str_utils::until(&*first)];
let mut post = &first[camel_case::from(&*first)..]; let mut post = &first[str_utils::from(&*first)..];
for var in def.variants { for var in def.variants {
let name = var.ident.name.as_str(); let name = var.ident.name.as_str();
let pre_match = partial_match(pre, &name); let pre_match = partial_match(pre, &name);
pre = &pre[..pre_match]; pre = &pre[..pre_match];
let pre_camel = camel_case::until(pre); let pre_camel = str_utils::until(pre);
pre = &pre[..pre_camel]; pre = &pre[..pre_camel];
while let Some((next, last)) = name[pre.len()..].chars().zip(pre.chars().rev()).next() { while let Some((next, last)) = name[pre.len()..].chars().zip(pre.chars().rev()).next() {
if next.is_numeric() { if next.is_numeric() {
@ -186,7 +186,7 @@ fn check_variant(
} }
if next.is_lowercase() { if next.is_lowercase() {
let last = pre.len() - last.len_utf8(); let last = pre.len() - last.len_utf8();
let last_camel = camel_case::until(&pre[..last]); let last_camel = str_utils::until(&pre[..last]);
pre = &pre[..last_camel]; pre = &pre[..last_camel];
} else { } else {
break; break;
@ -196,7 +196,7 @@ fn check_variant(
let post_match = partial_rmatch(post, &name); let post_match = partial_rmatch(post, &name);
let post_end = post.len() - post_match; let post_end = post.len() - post_match;
post = &post[post_end..]; post = &post[post_end..];
let post_camel = camel_case::from(post); let post_camel = str_utils::from(post);
post = &post[post_camel..]; post = &post[post_camel..];
} }
let (what, value) = match (pre.is_empty(), post.is_empty()) { let (what, value) = match (pre.is_empty(), post.is_empty()) {

View File

@ -37,7 +37,7 @@ pub mod sym_helper;
#[allow(clippy::module_name_repetitions)] #[allow(clippy::module_name_repetitions)]
pub mod ast_utils; pub mod ast_utils;
pub mod attrs; pub mod attrs;
pub mod camel_case; pub mod str_utils;
pub mod comparisons; pub mod comparisons;
pub mod consts; pub mod consts;
pub mod diagnostics; pub mod diagnostics;