1
1
//! lint on enum variants that are prefixed or suffixed by the same characters
2
2
3
- use clippy_utils:: camel_case ;
3
+ use clippy_utils:: str_utils ;
4
4
use clippy_utils:: diagnostics:: { span_lint, span_lint_and_help} ;
5
5
use clippy_utils:: source:: is_present_in_source;
6
6
use rustc_hir:: { EnumDef , Item , ItemKind } ;
@@ -171,22 +171,22 @@ fn check_variant(
171
171
}
172
172
}
173
173
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) ..] ;
176
176
for var in def. variants {
177
177
let name = var. ident . name . as_str ( ) ;
178
178
179
179
let pre_match = partial_match ( pre, & name) ;
180
180
pre = & pre[ ..pre_match] ;
181
- let pre_camel = camel_case :: until ( pre) ;
181
+ let pre_camel = str_utils :: until ( pre) ;
182
182
pre = & pre[ ..pre_camel] ;
183
183
while let Some ( ( next, last) ) = name[ pre. len ( ) ..] . chars ( ) . zip ( pre. chars ( ) . rev ( ) ) . next ( ) {
184
184
if next. is_numeric ( ) {
185
185
return ;
186
186
}
187
187
if next. is_lowercase ( ) {
188
188
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] ) ;
190
190
pre = & pre[ ..last_camel] ;
191
191
} else {
192
192
break ;
@@ -196,7 +196,7 @@ fn check_variant(
196
196
let post_match = partial_rmatch ( post, & name) ;
197
197
let post_end = post. len ( ) - post_match;
198
198
post = & post[ post_end..] ;
199
- let post_camel = camel_case :: from ( post) ;
199
+ let post_camel = str_utils :: from ( post) ;
200
200
post = & post[ post_camel..] ;
201
201
}
202
202
let ( what, value) = match ( pre. is_empty ( ) , post. is_empty ( ) ) {
0 commit comments