3030//! then mean that all later passes would have to check for these figments
3131//! and report an error, and it just seems like more mess in the end.)
3232
33- use super :: writeback:: Resolver ;
3433use super :: FnCtxt ;
3534
3635use crate :: expr_use_visitor as euv;
@@ -42,7 +41,6 @@ use rustc_hir::intravisit::{self, NestedVisitorMap, Visitor};
4241use rustc_infer:: infer:: UpvarRegion ;
4342use rustc_middle:: hir:: place:: { Place , PlaceBase , PlaceWithHirId , Projection , ProjectionKind } ;
4443use rustc_middle:: mir:: FakeReadCause ;
45- use rustc_middle:: ty:: fold:: TypeFoldable ;
4644use rustc_middle:: ty:: { self , Ty , TyCtxt , TypeckResults , UpvarSubsts } ;
4745use rustc_session:: lint;
4846use rustc_span:: sym;
@@ -167,7 +165,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
167165
168166 let closure_hir_id = self . tcx . hir ( ) . local_def_id_to_hir_id ( local_def_id) ;
169167 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) ;
171169 }
172170
173171 // We now fake capture information for all variables that are mentioned within the closure
@@ -467,13 +465,11 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
467465 closure_def_id : DefId ,
468466 capture_clause : hir:: CaptureBy ,
469467 span : Span ,
470- body : & ' tcx hir:: Body < ' tcx > ,
471468 ) {
472469 let need_migrations = self . compute_2229_migrations (
473470 closure_def_id,
474471 span,
475472 capture_clause,
476- body,
477473 self . typeck_results . borrow ( ) . closure_min_captures . get ( & closure_def_id) ,
478474 ) ;
479475
@@ -511,19 +507,8 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
511507 closure_def_id : DefId ,
512508 closure_span : Span ,
513509 closure_clause : hir:: CaptureBy ,
514- body : & ' tcx hir:: Body < ' tcx > ,
515510 min_captures : Option < & ty:: RootVariableMinCaptureList < ' tcx > > ,
516511 ) -> 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-
527512 let upvars = if let Some ( upvars) = self . tcx . upvars_mentioned ( closure_def_id) {
528513 upvars
529514 } else {
@@ -533,7 +518,7 @@ impl<'a, 'tcx> FnCtxt<'a, 'tcx> {
533518 let mut need_migrations = Vec :: new ( ) ;
534519
535520 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) ) ;
537522
538523 if !ty. needs_drop ( self . tcx , self . tcx . param_env ( closure_def_id. expect_local ( ) ) ) {
539524 continue ;
0 commit comments