@@ -11,7 +11,6 @@ use rustc_hir::{
1111 PatKind ,
1212} ;
1313use rustc_hir_typeck:: expr_use_visitor as euv;
14- use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
1514use rustc_lint:: { LateContext , LateLintPass } ;
1615use rustc_middle:: mir:: FakeReadCause ;
1716use rustc_middle:: ty:: { self , Ty , TyCtxt , UpvarId , UpvarPath } ;
@@ -102,7 +101,6 @@ fn should_skip<'tcx>(
102101fn check_closures < ' tcx > (
103102 ctx : & mut MutablyUsedVariablesCtxt < ' tcx > ,
104103 cx : & LateContext < ' tcx > ,
105- infcx : & InferCtxt < ' tcx > ,
106104 checked_closures : & mut FxHashSet < LocalDefId > ,
107105 closures : FxHashSet < LocalDefId > ,
108106) {
@@ -119,7 +117,7 @@ fn check_closures<'tcx>(
119117 . associated_body ( )
120118 . map ( |( _, body_id) | hir. body ( body_id) )
121119 {
122- euv:: ExprUseVisitor :: new ( ctx , infcx , closure, cx . param_env , cx . typeck_results ( ) ) . consume_body ( body) ;
120+ euv:: ExprUseVisitor :: for_clippy ( cx , closure, & mut * ctx ) . consume_body ( body) ;
123121 }
124122 }
125123}
@@ -196,8 +194,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
196194 async_closures : FxHashSet :: default ( ) ,
197195 tcx : cx. tcx ,
198196 } ;
199- let infcx = cx. tcx . infer_ctxt ( ) . build ( ) ;
200- euv:: ExprUseVisitor :: new ( & mut ctx, & infcx, fn_def_id, cx. param_env , cx. typeck_results ( ) ) . consume_body ( body) ;
197+ euv:: ExprUseVisitor :: for_clippy ( cx, fn_def_id, & mut ctx) . consume_body ( body) ;
201198
202199 let mut checked_closures = FxHashSet :: default ( ) ;
203200
@@ -210,13 +207,13 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
210207 }
211208 ControlFlow :: < ( ) > :: Continue ( ( ) )
212209 } ) ;
213- check_closures ( & mut ctx, cx, & infcx , & mut checked_closures, closures) ;
210+ check_closures ( & mut ctx, cx, & mut checked_closures, closures) ;
214211
215212 if is_async {
216213 while !ctx. async_closures . is_empty ( ) {
217214 let async_closures = ctx. async_closures . clone ( ) ;
218215 ctx. async_closures . clear ( ) ;
219- check_closures ( & mut ctx, cx, & infcx , & mut checked_closures, async_closures) ;
216+ check_closures ( & mut ctx, cx, & mut checked_closures, async_closures) ;
220217 }
221218 }
222219 ctx. generate_mutably_used_ids_from_aliases ( )
0 commit comments