11//! lint on enum variants that are prefixed or suffixed by the same characters
22
3- use clippy_utils:: camel_case ;
3+ use clippy_utils:: str_utils ;
44use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help} ;
55use clippy_utils:: source:: is_present_in_source;
66use rustc_hir:: { EnumDef , Item , ItemKind } ;
@@ -171,22 +171,22 @@ fn check_variant(
171171 }
172172 }
173173 let first = & def. variants [ 0 ] . ident . name . as_str ( ) ;
174- let mut pre = & first[ ..camel_case :: until ( & * first) ] ;
175- let mut post = & first[ camel_case :: from ( & * first) ..] ;
174+ let mut pre = & first[ ..str_utils :: until ( & * first) ] ;
175+ let mut post = & first[ str_utils :: from ( & * first) ..] ;
176176 for var in def. variants {
177177 let name = var. ident . name . as_str ( ) ;
178178
179179 let pre_match = partial_match ( pre, & name) ;
180180 pre = & pre[ ..pre_match] ;
181- let pre_camel = camel_case :: until ( pre) ;
181+ let pre_camel = str_utils :: until ( pre) ;
182182 pre = & pre[ ..pre_camel] ;
183183 while let Some ( ( next, last) ) = name[ pre. len ( ) ..] . chars ( ) . zip ( pre. chars ( ) . rev ( ) ) . next ( ) {
184184 if next. is_numeric ( ) {
185185 return ;
186186 }
187187 if next. is_lowercase ( ) {
188188 let last = pre. len ( ) - last. len_utf8 ( ) ;
189- let last_camel = camel_case :: until ( & pre[ ..last] ) ;
189+ let last_camel = str_utils :: until ( & pre[ ..last] ) ;
190190 pre = & pre[ ..last_camel] ;
191191 } else {
192192 break ;
@@ -196,7 +196,7 @@ fn check_variant(
196196 let post_match = partial_rmatch ( post, & name) ;
197197 let post_end = post. len ( ) - post_match;
198198 post = & post[ post_end..] ;
199- let post_camel = camel_case :: from ( post) ;
199+ let post_camel = str_utils :: from ( post) ;
200200 post = & post[ post_camel..] ;
201201 }
202202 let ( what, value) = match ( pre. is_empty ( ) , post. is_empty ( ) ) {
0 commit comments