1
1
use rustc:: hir:: { self , GenericParamKind , PatKind } ;
2
2
use rustc:: hir:: def:: Def ;
3
3
use rustc:: hir:: intravisit:: FnKind ;
4
+ use rustc:: lint;
4
5
use rustc:: ty;
5
6
use rustc_target:: spec:: abi:: Abi ;
6
7
use lint:: { EarlyContext , LateContext , LintContext , LintArray } ;
@@ -17,7 +18,7 @@ pub enum MethodLateContext {
17
18
PlainImpl ,
18
19
}
19
20
20
- pub fn method_context ( cx : & LateContext , id : ast:: NodeId ) -> MethodLateContext {
21
+ pub fn method_context ( cx : & LateContext < ' _ , ' _ > , id : ast:: NodeId ) -> MethodLateContext {
21
22
let def_id = cx. tcx . hir ( ) . local_def_id ( id) ;
22
23
let item = cx. tcx . associated_item ( def_id) ;
23
24
match item. container {
@@ -41,7 +42,7 @@ declare_lint! {
41
42
pub struct NonCamelCaseTypes ;
42
43
43
44
impl NonCamelCaseTypes {
44
- fn check_case ( & self , cx : & EarlyContext , sort : & str , ident : & Ident ) {
45
+ fn check_case ( & self , cx : & EarlyContext < ' _ > , sort : & str , ident : & Ident ) {
45
46
fn char_has_case ( c : char ) -> bool {
46
47
c. is_lowercase ( ) || c. is_uppercase ( )
47
48
}
@@ -115,7 +116,7 @@ impl LintPass for NonCamelCaseTypes {
115
116
}
116
117
117
118
impl EarlyLintPass for NonCamelCaseTypes {
118
- fn check_item ( & mut self , cx : & EarlyContext , it : & ast:: Item ) {
119
+ fn check_item ( & mut self , cx : & EarlyContext < ' _ > , it : & ast:: Item ) {
119
120
let has_repr_c = it. attrs
120
121
. iter ( )
121
122
. any ( |attr| {
@@ -138,11 +139,11 @@ impl EarlyLintPass for NonCamelCaseTypes {
138
139
}
139
140
}
140
141
141
- fn check_variant ( & mut self , cx : & EarlyContext , v : & ast:: Variant , _: & ast:: Generics ) {
142
+ fn check_variant ( & mut self , cx : & EarlyContext < ' _ > , v : & ast:: Variant , _: & ast:: Generics ) {
142
143
self . check_case ( cx, "variant" , & v. node . ident ) ;
143
144
}
144
145
145
- fn check_generic_param ( & mut self , cx : & EarlyContext , param : & ast:: GenericParam ) {
146
+ fn check_generic_param ( & mut self , cx : & EarlyContext < ' _ > , param : & ast:: GenericParam ) {
146
147
if let ast:: GenericParamKind :: Type { .. } = param. kind {
147
148
self . check_case ( cx, "type parameter" , & param. ident ) ;
148
149
}
@@ -190,7 +191,7 @@ impl NonSnakeCase {
190
191
}
191
192
192
193
/// Checks if a given identifier is snake case, and reports a diagnostic if not.
193
- fn check_snake_case ( & self , cx : & LateContext , sort : & str , ident : & Ident ) {
194
+ fn check_snake_case ( & self , cx : & LateContext < ' _ , ' _ > , sort : & str , ident : & Ident ) {
194
195
fn is_snake_case ( ident : & str ) -> bool {
195
196
if ident. is_empty ( ) {
196
197
return true ;
@@ -249,7 +250,7 @@ impl LintPass for NonSnakeCase {
249
250
}
250
251
251
252
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for NonSnakeCase {
252
- fn check_crate ( & mut self , cx : & LateContext , cr : & hir:: Crate ) {
253
+ fn check_crate ( & mut self , cx : & LateContext < ' _ , ' _ > , cr : & hir:: Crate ) {
253
254
let crate_ident = if let Some ( name) = & cx. tcx . sess . opts . crate_name {
254
255
Some ( Ident :: from_str ( name) )
255
256
} else {
@@ -286,16 +287,16 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
286
287
}
287
288
}
288
289
289
- fn check_generic_param ( & mut self , cx : & LateContext , param : & hir:: GenericParam ) {
290
+ fn check_generic_param ( & mut self , cx : & LateContext < ' _ , ' _ > , param : & hir:: GenericParam ) {
290
291
if let GenericParamKind :: Lifetime { .. } = param. kind {
291
292
self . check_snake_case ( cx, "lifetime" , & param. name . ident ( ) ) ;
292
293
}
293
294
}
294
295
295
296
fn check_fn (
296
297
& mut self ,
297
- cx : & LateContext ,
298
- fk : FnKind ,
298
+ cx : & LateContext < ' _ , ' _ > ,
299
+ fk : FnKind < ' _ > ,
299
300
_: & hir:: FnDecl ,
300
301
_: & hir:: Body ,
301
302
_: Span ,
@@ -324,13 +325,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
324
325
}
325
326
}
326
327
327
- fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
328
+ fn check_item ( & mut self , cx : & LateContext < ' _ , ' _ > , it : & hir:: Item ) {
328
329
if let hir:: ItemKind :: Mod ( _) = it. node {
329
330
self . check_snake_case ( cx, "module" , & it. ident ) ;
330
331
}
331
332
}
332
333
333
- fn check_trait_item ( & mut self , cx : & LateContext , item : & hir:: TraitItem ) {
334
+ fn check_trait_item ( & mut self , cx : & LateContext < ' _ , ' _ > , item : & hir:: TraitItem ) {
334
335
if let hir:: TraitItemKind :: Method ( _, hir:: TraitMethod :: Required ( pnames) ) = & item. node {
335
336
self . check_snake_case ( cx, "trait method" , & item. ident ) ;
336
337
for param_name in pnames {
@@ -339,15 +340,15 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonSnakeCase {
339
340
}
340
341
}
341
342
342
- fn check_pat ( & mut self , cx : & LateContext , p : & hir:: Pat ) {
343
+ fn check_pat ( & mut self , cx : & LateContext < ' _ , ' _ > , p : & hir:: Pat ) {
343
344
if let & PatKind :: Binding ( _, _, _, ident, _) = & p. node {
344
345
self . check_snake_case ( cx, "variable" , & ident) ;
345
346
}
346
347
}
347
348
348
349
fn check_struct_def (
349
350
& mut self ,
350
- cx : & LateContext ,
351
+ cx : & LateContext < ' _ , ' _ > ,
351
352
s : & hir:: VariantData ,
352
353
_: ast:: Name ,
353
354
_: & hir:: Generics ,
@@ -369,7 +370,7 @@ declare_lint! {
369
370
pub struct NonUpperCaseGlobals ;
370
371
371
372
impl NonUpperCaseGlobals {
372
- fn check_upper_case ( cx : & LateContext , sort : & str , ident : & Ident ) {
373
+ fn check_upper_case ( cx : & LateContext < ' _ , ' _ > , sort : & str , ident : & Ident ) {
373
374
let name = & ident. name . as_str ( ) ;
374
375
375
376
if name. chars ( ) . any ( |c| c. is_lowercase ( ) ) {
@@ -399,7 +400,7 @@ impl LintPass for NonUpperCaseGlobals {
399
400
}
400
401
401
402
impl < ' a , ' tcx > LateLintPass < ' a , ' tcx > for NonUpperCaseGlobals {
402
- fn check_item ( & mut self , cx : & LateContext , it : & hir:: Item ) {
403
+ fn check_item ( & mut self , cx : & LateContext < ' _ , ' _ > , it : & hir:: Item ) {
403
404
match it. node {
404
405
hir:: ItemKind :: Static ( ..) if !attr:: contains_name ( & it. attrs , "no_mangle" ) => {
405
406
NonUpperCaseGlobals :: check_upper_case ( cx, "static variable" , & it. ident ) ;
@@ -411,19 +412,19 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for NonUpperCaseGlobals {
411
412
}
412
413
}
413
414
414
- fn check_trait_item ( & mut self , cx : & LateContext , ti : & hir:: TraitItem ) {
415
+ fn check_trait_item ( & mut self , cx : & LateContext < ' _ , ' _ > , ti : & hir:: TraitItem ) {
415
416
if let hir:: TraitItemKind :: Const ( ..) = ti. node {
416
417
NonUpperCaseGlobals :: check_upper_case ( cx, "associated constant" , & ti. ident ) ;
417
418
}
418
419
}
419
420
420
- fn check_impl_item ( & mut self , cx : & LateContext , ii : & hir:: ImplItem ) {
421
+ fn check_impl_item ( & mut self , cx : & LateContext < ' _ , ' _ > , ii : & hir:: ImplItem ) {
421
422
if let hir:: ImplItemKind :: Const ( ..) = ii. node {
422
423
NonUpperCaseGlobals :: check_upper_case ( cx, "associated constant" , & ii. ident ) ;
423
424
}
424
425
}
425
426
426
- fn check_pat ( & mut self , cx : & LateContext , p : & hir:: Pat ) {
427
+ fn check_pat ( & mut self , cx : & LateContext < ' _ , ' _ > , p : & hir:: Pat ) {
427
428
// Lint for constants that look like binding identifiers (#7526)
428
429
if let PatKind :: Path ( hir:: QPath :: Resolved ( None , ref path) ) = p. node {
429
430
if let Def :: Const ( ..) = path. def {
0 commit comments