30
30
//! then mean that all later passes would have to check for these figments
31
31
//! and report an error, and it just seems like more mess in the end.)
32
32
33
- use super :: writeback:: Resolver ;
34
33
use super :: FnCtxt ;
35
34
36
35
use crate :: expr_use_visitor as euv;
@@ -42,7 +41,6 @@ use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
42
41
use rustc_infer:: infer:: UpvarRegion ;
43
42
use rustc_middle:: hir:: place:: { Place , PlaceBase , PlaceWithHirId , Projection , ProjectionKind } ;
44
43
use rustc_middle:: mir:: FakeReadCause ;
45
- use rustc_middle:: ty:: fold:: TypeFoldable ;
46
44
use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeckResults , UpvarSubsts } ;
47
45
use rustc_session:: lint;
48
46
use rustc_span:: sym;
@@ -167,7 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
167
165
168
166
let closure_hir_id = self . tcx . hir ( ) . local_def_id_to_hir_id ( local_def_id) ;
169
167
if should_do_migration_analysis ( self . tcx , closure_hir_id) {
170
- self . perform_2229_migration_anaysis ( closure_def_id, capture_clause, span, body ) ;
168
+ self . perform_2229_migration_anaysis ( closure_def_id, capture_clause, span) ;
171
169
}
172
170
173
171
// We now fake capture information for all variables that are mentioned within the closure
@@ -467,13 +465,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
467
465
closure_def_id : DefId ,
468
466
capture_clause : hir:: CaptureBy ,
469
467
span : Span ,
470
- body : & ' tcx hir:: Body < ' tcx > ,
471
468
) {
472
469
let need_migrations = self . compute_2229_migrations (
473
470
closure_def_id,
474
471
span,
475
472
capture_clause,
476
- body,
477
473
self . typeck_results . borrow ( ) . closure_min_captures . get ( & closure_def_id) ,
478
474
) ;
479
475
@@ -511,19 +507,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
511
507
closure_def_id : DefId ,
512
508
closure_span : Span ,
513
509
closure_clause : hir:: CaptureBy ,
514
- body : & ' tcx hir:: Body < ' tcx > ,
515
510
min_captures : Option < & ty:: RootVariableMinCaptureList < ' tcx > > ,
516
511
) -> Vec < hir:: HirId > {
517
- fn resolve_ty < T : TypeFoldable < ' tcx > > (
518
- fcx : & FnCtxt < ' _ , ' tcx > ,
519
- span : Span ,
520
- body : & ' tcx hir:: Body < ' tcx > ,
521
- ty : T ,
522
- ) -> T {
523
- let mut resolver = Resolver :: new ( fcx, & span, body) ;
524
- ty. fold_with ( & mut resolver)
525
- }
526
-
527
512
let upvars = if let Some ( upvars) = self . tcx . upvars_mentioned ( closure_def_id) {
528
513
upvars
529
514
} else {
@@ -533,7 +518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
533
518
let mut need_migrations = Vec :: new ( ) ;
534
519
535
520
for ( & var_hir_id, _) in upvars. iter ( ) {
536
- let ty = resolve_ty ( self , closure_span , body , self . node_ty ( var_hir_id) ) ;
521
+ let ty = self . infcx . resolve_vars_if_possible ( self . node_ty ( var_hir_id) ) ;
537
522
538
523
if !ty. needs_drop ( self . tcx , self . tcx . param_env ( closure_def_id. expect_local ( ) ) ) {
539
524
continue ;
0 commit comments