@@ -11,7 +11,6 @@ use rustc_hir::{
11
11
PatKind ,
12
12
} ;
13
13
use rustc_hir_typeck:: expr_use_visitor as euv;
14
- use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
15
14
use rustc_lint:: { LateContext , LateLintPass } ;
16
15
use rustc_middle:: mir:: FakeReadCause ;
17
16
use rustc_middle:: ty:: { self , Ty , TyCtxt , UpvarId , UpvarPath } ;
@@ -102,7 +101,6 @@ fn should_skip<'tcx>(
102
101
fn check_closures < ' tcx > (
103
102
ctx : & mut MutablyUsedVariablesCtxt < ' tcx > ,
104
103
cx : & LateContext < ' tcx > ,
105
- infcx : & InferCtxt < ' tcx > ,
106
104
checked_closures : & mut FxHashSet < LocalDefId > ,
107
105
closures : FxHashSet < LocalDefId > ,
108
106
) {
@@ -119,7 +117,7 @@ fn check_closures<'tcx>(
119
117
. associated_body ( )
120
118
. map ( |( _, body_id) | hir. body ( body_id) )
121
119
{
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) ;
123
121
}
124
122
}
125
123
}
@@ -196,8 +194,7 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
196
194
async_closures : FxHashSet :: default ( ) ,
197
195
tcx : cx. tcx ,
198
196
} ;
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) ;
201
198
202
199
let mut checked_closures = FxHashSet :: default ( ) ;
203
200
@@ -210,13 +207,13 @@ impl<'tcx> LateLintPass<'tcx> for NeedlessPassByRefMut<'tcx> {
210
207
}
211
208
ControlFlow :: < ( ) > :: Continue ( ( ) )
212
209
} ) ;
213
- check_closures ( & mut ctx, cx, & infcx , & mut checked_closures, closures) ;
210
+ check_closures ( & mut ctx, cx, & mut checked_closures, closures) ;
214
211
215
212
if is_async {
216
213
while !ctx. async_closures . is_empty ( ) {
217
214
let async_closures = ctx. async_closures . clone ( ) ;
218
215
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) ;
220
217
}
221
218
}
222
219
ctx. generate_mutably_used_ids_from_aliases ( )
0 commit comments