2
2
3
3
use crate :: reexport:: * ;
4
4
use crate :: utils:: {
5
- in_macro, last_line_of_span, match_def_path , paths, snippet_opt, span_lint, span_lint_and_sugg, span_lint_and_then,
5
+ in_macro, last_line_of_span, paths, snippet_opt, span_lint, span_lint_and_sugg, span_lint_and_then,
6
6
without_block_comments,
7
7
} ;
8
8
use if_chain:: if_chain;
@@ -11,7 +11,7 @@ use rustc::lint::{
11
11
in_external_macro, CheckLintNameResult , EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintArray ,
12
12
LintContext , LintPass ,
13
13
} ;
14
- use rustc:: ty:: { self , TyCtxt } ;
14
+ use rustc:: ty;
15
15
use rustc:: { declare_tool_lint, lint_array} ;
16
16
use rustc_errors:: Applicability ;
17
17
use semver:: Version ;
@@ -234,7 +234,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
234
234
}
235
235
236
236
fn check_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx Item ) {
237
- if is_relevant_item ( cx. tcx , item) {
237
+ if is_relevant_item ( cx, item) {
238
238
check_attrs ( cx, item. span , item. ident . name , & item. attrs )
239
239
}
240
240
match item. node {
@@ -302,13 +302,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
302
302
}
303
303
304
304
fn check_impl_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx ImplItem ) {
305
- if is_relevant_impl ( cx. tcx , item) {
305
+ if is_relevant_impl ( cx, item) {
306
306
check_attrs ( cx, item. span , item. ident . name , & item. attrs )
307
307
}
308
308
}
309
309
310
310
fn check_trait_item ( & mut self , cx : & LateContext < ' a , ' tcx > , item : & ' tcx TraitItem ) {
311
- if is_relevant_trait ( cx. tcx , item) {
311
+ if is_relevant_trait ( cx, item) {
312
312
check_attrs ( cx, item. span , item. ident . name , & item. attrs )
313
313
}
314
314
}
@@ -361,52 +361,52 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
361
361
}
362
362
}
363
363
364
- fn is_relevant_item < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , item : & Item ) -> bool {
364
+ fn is_relevant_item ( cx : & LateContext < ' _ , ' _ > , item : & Item ) -> bool {
365
365
if let ItemKind :: Fn ( _, _, _, eid) = item. node {
366
- is_relevant_expr ( tcx , tcx. body_tables ( eid) , & tcx. hir ( ) . body ( eid) . value )
366
+ is_relevant_expr ( cx , cx . tcx . body_tables ( eid) , & cx . tcx . hir ( ) . body ( eid) . value )
367
367
} else {
368
368
true
369
369
}
370
370
}
371
371
372
- fn is_relevant_impl < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , item : & ImplItem ) -> bool {
372
+ fn is_relevant_impl ( cx : & LateContext < ' _ , ' _ > , item : & ImplItem ) -> bool {
373
373
match item. node {
374
- ImplItemKind :: Method ( _, eid) => is_relevant_expr ( tcx , tcx. body_tables ( eid) , & tcx. hir ( ) . body ( eid) . value ) ,
374
+ ImplItemKind :: Method ( _, eid) => is_relevant_expr ( cx , cx . tcx . body_tables ( eid) , & cx . tcx . hir ( ) . body ( eid) . value ) ,
375
375
_ => false ,
376
376
}
377
377
}
378
378
379
- fn is_relevant_trait < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , item : & TraitItem ) -> bool {
379
+ fn is_relevant_trait ( cx : & LateContext < ' _ , ' _ > , item : & TraitItem ) -> bool {
380
380
match item. node {
381
381
TraitItemKind :: Method ( _, TraitMethod :: Required ( _) ) => true ,
382
382
TraitItemKind :: Method ( _, TraitMethod :: Provided ( eid) ) => {
383
- is_relevant_expr ( tcx , tcx. body_tables ( eid) , & tcx. hir ( ) . body ( eid) . value )
383
+ is_relevant_expr ( cx , cx . tcx . body_tables ( eid) , & cx . tcx . hir ( ) . body ( eid) . value )
384
384
} ,
385
385
_ => false ,
386
386
}
387
387
}
388
388
389
- fn is_relevant_block < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , tables : & ty:: TypeckTables < ' _ > , block : & Block ) -> bool {
389
+ fn is_relevant_block ( cx : & LateContext < ' _ , ' _ > , tables : & ty:: TypeckTables < ' _ > , block : & Block ) -> bool {
390
390
if let Some ( stmt) = block. stmts . first ( ) {
391
391
match & stmt. node {
392
392
StmtKind :: Local ( _) => true ,
393
- StmtKind :: Expr ( expr) | StmtKind :: Semi ( expr) => is_relevant_expr ( tcx , tables, expr) ,
393
+ StmtKind :: Expr ( expr) | StmtKind :: Semi ( expr) => is_relevant_expr ( cx , tables, expr) ,
394
394
_ => false ,
395
395
}
396
396
} else {
397
- block. expr . as_ref ( ) . map_or ( false , |e| is_relevant_expr ( tcx , tables, e) )
397
+ block. expr . as_ref ( ) . map_or ( false , |e| is_relevant_expr ( cx , tables, e) )
398
398
}
399
399
}
400
400
401
- fn is_relevant_expr < ' a , ' tcx > ( tcx : TyCtxt < ' a , ' tcx , ' tcx > , tables : & ty:: TypeckTables < ' _ > , expr : & Expr ) -> bool {
401
+ fn is_relevant_expr ( cx : & LateContext < ' _ , ' _ > , tables : & ty:: TypeckTables < ' _ > , expr : & Expr ) -> bool {
402
402
match & expr. node {
403
- ExprKind :: Block ( block, _) => is_relevant_block ( tcx , tables, block) ,
404
- ExprKind :: Ret ( Some ( e) ) => is_relevant_expr ( tcx , tables, e) ,
403
+ ExprKind :: Block ( block, _) => is_relevant_block ( cx , tables, block) ,
404
+ ExprKind :: Ret ( Some ( e) ) => is_relevant_expr ( cx , tables, e) ,
405
405
ExprKind :: Ret ( None ) | ExprKind :: Break ( _, None ) => false ,
406
406
ExprKind :: Call ( path_expr, _) => {
407
407
if let ExprKind :: Path ( qpath) = & path_expr. node {
408
408
if let Some ( fun_id) = tables. qpath_def ( qpath, path_expr. hir_id ) . opt_def_id ( ) {
409
- !match_def_path ( tcx , fun_id, & paths:: BEGIN_PANIC )
409
+ !cx . match_def_path ( fun_id, & paths:: BEGIN_PANIC )
410
410
} else {
411
411
true
412
412
}
0 commit comments