@@ -6,7 +6,7 @@ use rustc::lint::{EarlyContext, EarlyLintPass, Lint, LintArray, LintPass};
6
6
use rustc:: { declare_tool_lint, impl_lint_pass} ;
7
7
use syntax:: ast:: * ;
8
8
use syntax:: source_map:: Span ;
9
- use syntax:: symbol:: { InternedString , LocalInternedString } ;
9
+ use syntax:: symbol:: Symbol ;
10
10
11
11
declare_clippy_lint ! {
12
12
/// **What it does:** Detects enumeration variants that are prefixed or suffixed
@@ -102,7 +102,7 @@ declare_clippy_lint! {
102
102
}
103
103
104
104
pub struct EnumVariantNames {
105
- modules : Vec < ( InternedString , String ) > ,
105
+ modules : Vec < ( Symbol , String ) > ,
106
106
threshold : u64 ,
107
107
}
108
108
@@ -122,10 +122,6 @@ impl_lint_pass!(EnumVariantNames => [
122
122
MODULE_INCEPTION
123
123
] ) ;
124
124
125
- fn var2str ( var : & Variant ) -> LocalInternedString {
126
- var. ident . as_str ( )
127
- }
128
-
129
125
/// Returns the number of chars that match from the start
130
126
fn partial_match ( pre : & str , name : & str ) -> usize {
131
127
let mut name_iter = name. chars ( ) ;
@@ -157,7 +153,7 @@ fn check_variant(
157
153
return ;
158
154
}
159
155
for var in & def. variants {
160
- let name = var2str ( var) ;
156
+ let name = var. ident . name . as_str ( ) ;
161
157
if partial_match ( item_name, & name) == item_name_chars
162
158
&& name. chars ( ) . nth ( item_name_chars) . map_or ( false , |c| !c. is_lowercase ( ) )
163
159
&& name. chars ( ) . nth ( item_name_chars + 1 ) . map_or ( false , |c| !c. is_numeric ( ) )
@@ -168,11 +164,11 @@ fn check_variant(
168
164
span_lint ( cx, lint, var. span , "Variant name ends with the enum's name" ) ;
169
165
}
170
166
}
171
- let first = var2str ( & def. variants [ 0 ] ) ;
167
+ let first = & def. variants [ 0 ] . ident . name . as_str ( ) ;
172
168
let mut pre = & first[ ..camel_case:: until ( & * first) ] ;
173
169
let mut post = & first[ camel_case:: from ( & * first) ..] ;
174
170
for var in & def. variants {
175
- let name = var2str ( var) ;
171
+ let name = var. ident . name . as_str ( ) ;
176
172
177
173
let pre_match = partial_match ( pre, & name) ;
178
174
pre = & pre[ ..pre_match] ;
@@ -245,14 +241,14 @@ impl EarlyLintPass for EnumVariantNames {
245
241
246
242
#[ allow( clippy:: similar_names) ]
247
243
fn check_item ( & mut self , cx : & EarlyContext < ' _ > , item : & Item ) {
248
- let item_name = item. ident . as_str ( ) ;
244
+ let item_name = item. ident . name . as_str ( ) ;
249
245
let item_name_chars = item_name. chars ( ) . count ( ) ;
250
246
let item_camel = to_camel_case ( & item_name) ;
251
247
if !item. span . from_expansion ( ) && is_present_in_source ( cx, item. span ) {
252
248
if let Some ( & ( ref mod_name, ref mod_camel) ) = self . modules . last ( ) {
253
249
// constants don't have surrounding modules
254
250
if !mod_camel. is_empty ( ) {
255
- if mod_name. as_symbol ( ) == item. ident . name {
251
+ if mod_name == & item. ident . name {
256
252
if let ItemKind :: Mod ( ..) = item. node {
257
253
span_lint (
258
254
cx,
@@ -299,6 +295,6 @@ impl EarlyLintPass for EnumVariantNames {
299
295
} ;
300
296
check_variant ( cx, self . threshold , def, & item_name, item_name_chars, item. span , lint) ;
301
297
}
302
- self . modules . push ( ( item_name . as_interned_str ( ) , item_camel) ) ;
298
+ self . modules . push ( ( item . ident . name , item_camel) ) ;
303
299
}
304
300
}
0 commit comments