@@ -13,8 +13,8 @@ use rustc::hir::def::Def;
13
13
use rustc:: hir:: intravisit:: FnKind ;
14
14
use rustc:: ty;
15
15
use 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 } ;
18
18
use syntax:: ast;
19
19
use syntax:: attr;
20
20
use syntax_pos:: Span ;
@@ -50,7 +50,7 @@ declare_lint! {
50
50
pub struct NonCamelCaseTypes ;
51
51
52
52
impl 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 ) {
54
54
fn char_has_case ( c : char ) -> bool {
55
55
c. is_lowercase ( ) || c. is_uppercase ( )
56
56
}
@@ -114,12 +114,12 @@ impl LintPass for NonCamelCaseTypes {
114
114
}
115
115
}
116
116
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 ) {
119
119
let has_repr_c = it. attrs
120
120
. iter ( )
121
121
. any ( |attr| {
122
- attr:: find_repr_attrs ( & cx. tcx . sess . parse_sess , attr)
122
+ attr:: find_repr_attrs ( & cx. sess . parse_sess , attr)
123
123
. iter ( )
124
124
. any ( |r| r == & attr:: ReprC )
125
125
} ) ;
@@ -129,27 +129,22 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonCamelCaseTypes {
129
129
}
130
130
131
131
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 ) ,
137
137
_ => ( ) ,
138
138
}
139
139
}
140
140
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 ) ;
143
143
}
144
144
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 ) ;
153
148
}
154
149
}
155
150
}
0 commit comments