@@ -6,7 +6,7 @@ use rustc::lint::{EarlyContext, EarlyLintPass, Lint, LintArray, LintPass};
66use rustc:: { declare_tool_lint, impl_lint_pass} ;
77use syntax:: ast:: * ;
88use syntax:: source_map:: Span ;
9- use syntax:: symbol:: { InternedString , LocalInternedString } ;
9+ use syntax:: symbol:: Symbol ;
1010
1111declare_clippy_lint ! {
1212 /// **What it does:** Detects enumeration variants that are prefixed or suffixed
@@ -102,7 +102,7 @@ declare_clippy_lint! {
102102}
103103
104104pub struct EnumVariantNames {
105- modules : Vec < ( InternedString , String ) > ,
105+ modules : Vec < ( Symbol , String ) > ,
106106 threshold : u64 ,
107107}
108108
@@ -122,10 +122,6 @@ impl_lint_pass!(EnumVariantNames => [
122122 MODULE_INCEPTION
123123] ) ;
124124
125- fn var2str ( var : & Variant ) -> LocalInternedString {
126- var. ident . as_str ( )
127- }
128-
129125/// Returns the number of chars that match from the start
130126fn partial_match ( pre : & str , name : & str ) -> usize {
131127 let mut name_iter = name. chars ( ) ;
@@ -157,7 +153,7 @@ fn check_variant(
157153 return ;
158154 }
159155 for var in & def. variants {
160- let name = var2str ( var) ;
156+ let name = var. ident . name . as_str ( ) ;
161157 if partial_match ( item_name, & name) == item_name_chars
162158 && name. chars ( ) . nth ( item_name_chars) . map_or ( false , |c| !c. is_lowercase ( ) )
163159 && name. chars ( ) . nth ( item_name_chars + 1 ) . map_or ( false , |c| !c. is_numeric ( ) )
@@ -168,11 +164,11 @@ fn check_variant(
168164 span_lint ( cx, lint, var. span , "Variant name ends with the enum's name" ) ;
169165 }
170166 }
171- let first = var2str ( & def. variants [ 0 ] ) ;
167+ let first = & def. variants [ 0 ] . ident . name . as_str ( ) ;
172168 let mut pre = & first[ ..camel_case:: until ( & * first) ] ;
173169 let mut post = & first[ camel_case:: from ( & * first) ..] ;
174170 for var in & def. variants {
175- let name = var2str ( var) ;
171+ let name = var. ident . name . as_str ( ) ;
176172
177173 let pre_match = partial_match ( pre, & name) ;
178174 pre = & pre[ ..pre_match] ;
@@ -245,14 +241,14 @@ impl EarlyLintPass for EnumVariantNames {
245241
246242 #[ allow( clippy:: similar_names) ]
247243 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 ( ) ;
249245 let item_name_chars = item_name. chars ( ) . count ( ) ;
250246 let item_camel = to_camel_case ( & item_name) ;
251247 if !item. span . from_expansion ( ) && is_present_in_source ( cx, item. span ) {
252248 if let Some ( & ( ref mod_name, ref mod_camel) ) = self . modules . last ( ) {
253249 // constants don't have surrounding modules
254250 if !mod_camel. is_empty ( ) {
255- if mod_name. as_symbol ( ) == item. ident . name {
251+ if mod_name == & item. ident . name {
256252 if let ItemKind :: Mod ( ..) = item. node {
257253 span_lint (
258254 cx,
@@ -299,6 +295,6 @@ impl EarlyLintPass for EnumVariantNames {
299295 } ;
300296 check_variant ( cx, self . threshold , def, & item_name, item_name_chars, item. span , lint) ;
301297 }
302- self . modules . push ( ( item_name . as_interned_str ( ) , item_camel) ) ;
298+ self . modules . push ( ( item . ident . name , item_camel) ) ;
303299 }
304300}
0 commit comments