@@ -81,19 +81,12 @@ impl NonCamelCaseTypes {
81
81
. concat ( )
82
82
}
83
83
84
- let s = name. as_str ( ) ;
85
-
86
84
if !is_camel_case ( name) {
87
- let c = to_camel_case ( & s ) ;
85
+ let c = to_camel_case ( & name . as_str ( ) ) ;
88
86
let m = if c. is_empty ( ) {
89
- format ! ( "{} `{}` should have a camel case name such as `CamelCase`" ,
90
- sort,
91
- s)
87
+ format ! ( "{} `{}` should have a camel case name such as `CamelCase`" , sort, name)
92
88
} else {
93
- format ! ( "{} `{}` should have a camel case name such as `{}`" ,
94
- sort,
95
- s,
96
- c)
89
+ format ! ( "{} `{}` should have a camel case name such as `{}`" , sort, name, c)
97
90
} ;
98
91
cx. span_lint ( NON_CAMEL_CASE_TYPES , span, & m[ ..] ) ;
99
92
}
@@ -326,21 +319,19 @@ pub struct NonUpperCaseGlobals;
326
319
327
320
impl NonUpperCaseGlobals {
328
321
fn check_upper_case ( cx : & LateContext , sort : & str , name : ast:: Name , span : Span ) {
329
- let s = name. as_str ( ) ;
330
-
331
- if s. chars ( ) . any ( |c| c. is_lowercase ( ) ) {
332
- let uc = NonSnakeCase :: to_snake_case ( & s) . to_uppercase ( ) ;
333
- if uc != & s[ ..] {
322
+ if name. as_str ( ) . chars ( ) . any ( |c| c. is_lowercase ( ) ) {
323
+ let uc = NonSnakeCase :: to_snake_case ( & name. as_str ( ) ) . to_uppercase ( ) ;
324
+ if name != & * uc {
334
325
cx. span_lint ( NON_UPPER_CASE_GLOBALS ,
335
326
span,
336
327
& format ! ( "{} `{}` should have an upper case name such as `{}`" ,
337
328
sort,
338
- s ,
329
+ name ,
339
330
uc) ) ;
340
331
} else {
341
332
cx. span_lint ( NON_UPPER_CASE_GLOBALS ,
342
333
span,
343
- & format ! ( "{} `{}` should have an upper case name" , sort, s ) ) ;
334
+ & format ! ( "{} `{}` should have an upper case name" , sort, name ) ) ;
344
335
}
345
336
}
346
337
}
0 commit comments