22
33use crate :: reexport:: * ;
44use 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,
66 without_block_comments,
77} ;
88use if_chain:: if_chain;
@@ -11,7 +11,7 @@ use rustc::lint::{
1111 in_external_macro, CheckLintNameResult , EarlyContext , EarlyLintPass , LateContext , LateLintPass , LintArray ,
1212 LintContext , LintPass ,
1313} ;
14- use rustc:: ty:: { self , TyCtxt } ;
14+ use rustc:: ty;
1515use rustc:: { declare_tool_lint, lint_array} ;
1616use rustc_errors:: Applicability ;
1717use semver:: Version ;
@@ -234,7 +234,7 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
234234 }
235235
236236 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) {
238238 check_attrs ( cx, item. span , item. ident . name , & item. attrs )
239239 }
240240 match item. node {
@@ -302,13 +302,13 @@ impl<'a, 'tcx> LateLintPass<'a, 'tcx> for AttrPass {
302302 }
303303
304304 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) {
306306 check_attrs ( cx, item. span , item. ident . name , & item. attrs )
307307 }
308308 }
309309
310310 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) {
312312 check_attrs ( cx, item. span , item. ident . name , & item. attrs )
313313 }
314314 }
@@ -361,52 +361,52 @@ fn check_clippy_lint_names(cx: &LateContext<'_, '_>, items: &[NestedMetaItem]) {
361361 }
362362}
363363
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 {
365365 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 )
367367 } else {
368368 true
369369 }
370370}
371371
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 {
373373 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 ) ,
375375 _ => false ,
376376 }
377377}
378378
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 {
380380 match item. node {
381381 TraitItemKind :: Method ( _, TraitMethod :: Required ( _) ) => true ,
382382 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 )
384384 } ,
385385 _ => false ,
386386 }
387387}
388388
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 {
390390 if let Some ( stmt) = block. stmts . first ( ) {
391391 match & stmt. node {
392392 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) ,
394394 _ => false ,
395395 }
396396 } 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) )
398398 }
399399}
400400
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 {
402402 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) ,
405405 ExprKind :: Ret ( None ) | ExprKind :: Break ( _, None ) => false ,
406406 ExprKind :: Call ( path_expr, _) => {
407407 if let ExprKind :: Path ( qpath) = & path_expr. node {
408408 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 )
410410 } else {
411411 true
412412 }
0 commit comments