@@ -13,8 +13,8 @@ use rustc::hir::def::Def;
1313use rustc:: hir:: intravisit:: FnKind ;
1414use rustc:: ty;
1515use rustc_target:: spec:: abi:: Abi ;
16- use lint:: { LateContext , LintContext , LintArray } ;
17- use lint:: { LintPass , LateLintPass } ;
16+ use lint:: { EarlyContext , LateContext , LintContext , LintArray } ;
17+ use lint:: { EarlyLintPass , LintPass , LateLintPass } ;
1818use syntax:: ast;
1919use syntax:: attr;
2020use syntax_pos:: Span ;
@@ -50,7 +50,7 @@ declare_lint! {
5050pub struct NonCamelCaseTypes ;
5151
5252impl NonCamelCaseTypes {
53- fn check_case ( & self , cx : & LateContext , sort : & str , name : ast:: Name , span : Span ) {
53+ fn check_case ( & self , cx : & EarlyContext , sort : & str , name : ast:: Name , span : Span ) {
5454 fn char_has_case ( c : char ) -> bool {
5555 c. is_lowercase ( ) || c. is_uppercase ( )
5656 }
@@ -114,12 +114,12 @@ impl LintPass for NonCamelCaseTypes {
114114 }
115115}
116116
117- impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for NonCamelCaseTypes {
118- fn check_item ( & mut self , cx : & LateContext , it : & hir :: Item ) {
117+ impl EarlyLintPass for NonCamelCaseTypes {
118+ fn check_item ( & mut self , cx : & EarlyContext , it : & ast :: Item ) {
119119 let has_repr_c = it. attrs
120120 . iter ( )
121121 . any ( |attr| {
122- attr:: find_repr_attrs ( & cx. tcx . sess . parse_sess , attr)
122+ attr:: find_repr_attrs ( & cx. sess . parse_sess , attr)
123123 . iter ( )
124124 . any ( |r| r == & attr:: ReprC )
125125 } ) ;
@@ -129,27 +129,22 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
129129 }
130130
131131 match it. node {
132- hir :: ItemKind :: Ty ( ..) |
133- hir :: ItemKind :: Enum ( ..) |
134- hir :: ItemKind :: Struct ( ..) |
135- hir :: ItemKind :: Union ( ..) => self . check_case ( cx, "type" , it. name , it. span ) ,
136- hir :: ItemKind :: Trait ( ..) => self . check_case ( cx, "trait" , it. name , it. span ) ,
132+ ast :: ItemKind :: Ty ( ..) |
133+ ast :: ItemKind :: Enum ( ..) |
134+ ast :: ItemKind :: Struct ( ..) |
135+ ast :: ItemKind :: Union ( ..) => self . check_case ( cx, "type" , it. ident . name , it. span ) ,
136+ ast :: ItemKind :: Trait ( ..) => self . check_case ( cx, "trait" , it. ident . name , it. span ) ,
137137 _ => ( ) ,
138138 }
139139 }
140140
141- fn check_variant ( & mut self , cx : & LateContext , v : & hir :: Variant , _: & hir :: Generics ) {
142- self . check_case ( cx, "variant" , v. node . name , v. span ) ;
141+ fn check_variant ( & mut self , cx : & EarlyContext , v : & ast :: Variant , _: & ast :: Generics ) {
142+ self . check_case ( cx, "variant" , v. node . ident . name , v. span ) ;
143143 }
144144
145- fn check_generic_param ( & mut self , cx : & LateContext , param : & hir:: GenericParam ) {
146- match param. kind {
147- GenericParamKind :: Lifetime { .. } => { }
148- GenericParamKind :: Type { synthetic, .. } => {
149- if synthetic. is_none ( ) {
150- self . check_case ( cx, "type parameter" , param. name . ident ( ) . name , param. span ) ;
151- }
152- }
145+ fn check_generic_param ( & mut self , cx : & EarlyContext , param : & ast:: GenericParam ) {
146+ if let ast:: GenericParamKind :: Type { .. } = param. kind {
147+ self . check_case ( cx, "type parameter" , param. ident . name , param. ident . span ) ;
153148 }
154149 }
155150}
0 commit comments