@@ -53,17 +53,17 @@ declare_lint! {
5353pub struct NonCamelCaseTypes ;
5454
5555impl NonCamelCaseTypes {
56- fn check_case ( & self , cx : & LateContext , sort : & str , ident : ast:: Ident , span : Span ) {
57- fn is_camel_case ( ident : ast:: Ident ) -> bool {
58- let ident = ident . name . as_str ( ) ;
59- if ident . is_empty ( ) {
56+ fn check_case ( & self , cx : & LateContext , sort : & str , name : ast:: Name , span : Span ) {
57+ fn is_camel_case ( name : ast:: Name ) -> bool {
58+ let name = name. as_str ( ) ;
59+ if name . is_empty ( ) {
6060 return true ;
6161 }
62- let ident = ident . trim_matches ( '_' ) ;
62+ let name = name . trim_matches ( '_' ) ;
6363
6464 // start with a non-lowercase letter rather than non-uppercase
6565 // ones (some scripts don't have a concept of upper/lowercase)
66- !ident . is_empty ( ) && !ident . char_at ( 0 ) . is_lowercase ( ) && !ident . contains ( '_' )
66+ !name . is_empty ( ) && !name . char_at ( 0 ) . is_lowercase ( ) && !name . contains ( '_' )
6767 }
6868
6969 fn to_camel_case ( s : & str ) -> String {
@@ -76,9 +76,9 @@ impl NonCamelCaseTypes {
7676 ) ) . collect :: < Vec < _ > > ( ) . concat ( )
7777 }
7878
79- let s = ident . name . as_str ( ) ;
79+ let s = name. as_str ( ) ;
8080
81- if !is_camel_case ( ident ) {
81+ if !is_camel_case ( name ) {
8282 let c = to_camel_case ( & s) ;
8383 let m = if c. is_empty ( ) {
8484 format ! ( "{} `{}` should have a camel case name such as `CamelCase`" , sort, s)
@@ -110,16 +110,16 @@ impl LateLintPass for NonCamelCaseTypes {
110110
111111 match it. node {
112112 hir:: ItemTy ( ..) | hir:: ItemStruct ( ..) => {
113- self . check_case ( cx, "type" , it. ident , it. span )
113+ self . check_case ( cx, "type" , it. name , it. span )
114114 }
115115 hir:: ItemTrait ( ..) => {
116- self . check_case ( cx, "trait" , it. ident , it. span )
116+ self . check_case ( cx, "trait" , it. name , it. span )
117117 }
118118 hir:: ItemEnum ( ref enum_definition, _) => {
119119 if has_extern_repr {
120120 return ;
121121 }
122- self . check_case ( cx, "type" , it. ident , it. span ) ;
122+ self . check_case ( cx, "type" , it. name , it. span ) ;
123123 for variant in & enum_definition. variants {
124124 self . check_case ( cx, "variant" , variant. node . name , variant. span ) ;
125125 }
@@ -130,7 +130,7 @@ impl LateLintPass for NonCamelCaseTypes {
130130
131131 fn check_generics ( & mut self , cx : & LateContext , it : & hir:: Generics ) {
132132 for gen in it. ty_params . iter ( ) {
133- self . check_case ( cx, "type parameter" , gen. ident , gen. span ) ;
133+ self . check_case ( cx, "type parameter" , gen. name , gen. span ) ;
134134 }
135135 }
136136}
@@ -237,31 +237,31 @@ impl LateLintPass for NonSnakeCase {
237237 fk : FnKind , _: & hir:: FnDecl ,
238238 _: & hir:: Block , span : Span , id : ast:: NodeId ) {
239239 match fk {
240- FnKind :: Method ( ident , _, _) => match method_context ( cx, id, span) {
240+ FnKind :: Method ( name , _, _) => match method_context ( cx, id, span) {
241241 MethodLateContext :: PlainImpl => {
242- self . check_snake_case ( cx, "method" , & ident . name . as_str ( ) , Some ( span) )
242+ self . check_snake_case ( cx, "method" , & name. as_str ( ) , Some ( span) )
243243 } ,
244244 MethodLateContext :: TraitDefaultImpl => {
245- self . check_snake_case ( cx, "trait method" , & ident . name . as_str ( ) , Some ( span) )
245+ self . check_snake_case ( cx, "trait method" , & name. as_str ( ) , Some ( span) )
246246 } ,
247247 _ => ( ) ,
248248 } ,
249- FnKind :: ItemFn ( ident , _, _, _, _, _) => {
250- self . check_snake_case ( cx, "function" , & ident . name . as_str ( ) , Some ( span) )
249+ FnKind :: ItemFn ( name , _, _, _, _, _) => {
250+ self . check_snake_case ( cx, "function" , & name. as_str ( ) , Some ( span) )
251251 } ,
252252 _ => ( ) ,
253253 }
254254 }
255255
256256 fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
257257 if let hir:: ItemMod ( _) = it. node {
258- self . check_snake_case ( cx, "module" , & it. ident . name . as_str ( ) , Some ( it. span ) ) ;
258+ self . check_snake_case ( cx, "module" , & it. name . as_str ( ) , Some ( it. span ) ) ;
259259 }
260260 }
261261
262262 fn check_trait_item ( & mut self , cx : & LateContext , trait_item : & hir:: TraitItem ) {
263263 if let hir:: MethodTraitItem ( _, None ) = trait_item. node {
264- self . check_snake_case ( cx, "trait method" , & trait_item. ident . name . as_str ( ) ,
264+ self . check_snake_case ( cx, "trait method" , & trait_item. name . as_str ( ) ,
265265 Some ( trait_item. span ) ) ;
266266 }
267267 }
@@ -281,10 +281,10 @@ impl LateLintPass for NonSnakeCase {
281281 }
282282
283283 fn check_struct_def ( & mut self , cx : & LateContext , s : & hir:: StructDef ,
284- _: ast:: Ident , _: & hir:: Generics , _: ast:: NodeId ) {
284+ _: ast:: Name , _: & hir:: Generics , _: ast:: NodeId ) {
285285 for sf in & s. fields {
286- if let hir:: StructField_ { kind : hir:: NamedField ( ident , _) , .. } = sf. node {
287- self . check_snake_case ( cx, "structure field" , & ident . name . as_str ( ) ,
286+ if let hir:: StructField_ { kind : hir:: NamedField ( name , _) , .. } = sf. node {
287+ self . check_snake_case ( cx, "structure field" , & name. as_str ( ) ,
288288 Some ( sf. span ) ) ;
289289 }
290290 }
@@ -301,8 +301,8 @@ declare_lint! {
301301pub struct NonUpperCaseGlobals ;
302302
303303impl NonUpperCaseGlobals {
304- fn check_upper_case ( cx : & LateContext , sort : & str , ident : ast:: Ident , span : Span ) {
305- let s = ident . name . as_str ( ) ;
304+ fn check_upper_case ( cx : & LateContext , sort : & str , name : ast:: Name , span : Span ) {
305+ let s = name. as_str ( ) ;
306306
307307 if s. chars ( ) . any ( |c| c. is_lowercase ( ) ) {
308308 let uc = NonSnakeCase :: to_snake_case ( & s) . to_uppercase ( ) ;
@@ -330,10 +330,10 @@ impl LateLintPass for NonUpperCaseGlobals {
330330 match it. node {
331331 // only check static constants
332332 hir:: ItemStatic ( _, hir:: MutImmutable , _) => {
333- NonUpperCaseGlobals :: check_upper_case ( cx, "static constant" , it. ident , it. span ) ;
333+ NonUpperCaseGlobals :: check_upper_case ( cx, "static constant" , it. name , it. span ) ;
334334 }
335335 hir:: ItemConst ( ..) => {
336- NonUpperCaseGlobals :: check_upper_case ( cx, "constant" , it. ident , it. span ) ;
336+ NonUpperCaseGlobals :: check_upper_case ( cx, "constant" , it. name , it. span ) ;
337337 }
338338 _ => { }
339339 }
@@ -343,7 +343,7 @@ impl LateLintPass for NonUpperCaseGlobals {
343343 match ti. node {
344344 hir:: ConstTraitItem ( ..) => {
345345 NonUpperCaseGlobals :: check_upper_case ( cx, "associated constant" ,
346- ti. ident , ti. span ) ;
346+ ti. name , ti. span ) ;
347347 }
348348 _ => { }
349349 }
@@ -353,7 +353,7 @@ impl LateLintPass for NonUpperCaseGlobals {
353353 match ii. node {
354354 hir:: ConstImplItem ( ..) => {
355355 NonUpperCaseGlobals :: check_upper_case ( cx, "associated constant" ,
356- ii. ident , ii. span ) ;
356+ ii. name , ii. span ) ;
357357 }
358358 _ => { }
359359 }
@@ -364,7 +364,7 @@ impl LateLintPass for NonUpperCaseGlobals {
364364 match ( & p. node , cx. tcx . def_map . borrow ( ) . get ( & p. id ) . map ( |d| d. full_def ( ) ) ) {
365365 ( & hir:: PatIdent ( _, ref path1, _) , Some ( def:: DefConst ( ..) ) ) => {
366366 NonUpperCaseGlobals :: check_upper_case ( cx, "constant in pattern" ,
367- path1. node , p. span ) ;
367+ path1. node . name , p. span ) ;
368368 }
369369 _ => { }
370370 }
0 commit comments