@@ -121,9 +121,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
121
121
None
122
122
} ;
123
123
124
- self . tcx . with_freevars ( closure_hir_id , | freevars| {
124
+ if let Some ( freevars ) = self . tcx . freevars ( closure_def_id ) {
125
125
let mut freevar_list: Vec < ty:: UpvarId > = Vec :: with_capacity ( freevars. len ( ) ) ;
126
- for freevar in freevars {
126
+ for freevar in freevars. iter ( ) {
127
127
let upvar_id = ty:: UpvarId {
128
128
var_path : ty:: UpvarPath {
129
129
hir_id : freevar. var_id ( ) ,
@@ -155,14 +155,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
155
155
}
156
156
// Add the vector of freevars to the map keyed with the closure id.
157
157
// This gives us an easier access to them without having to call
158
- // with_freevars again..
158
+ // tcx.freevars again..
159
159
if !freevar_list. is_empty ( ) {
160
160
self . tables
161
161
. borrow_mut ( )
162
162
. upvar_list
163
163
. insert ( closure_def_id, freevar_list) ;
164
164
}
165
- } ) ;
165
+ }
166
166
167
167
let body_owner_def_id = self . tcx . hir ( ) . body_owner_def_id ( body. id ( ) ) ;
168
168
let region_scope_tree = & self . tcx . region_scope_tree ( body_owner_def_id) ;
@@ -244,17 +244,17 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
244
244
// This may change if abstract return types of some sort are
245
245
// implemented.
246
246
let tcx = self . tcx ;
247
- let closure_def_index = tcx. hir ( ) . local_def_id_from_hir_id ( closure_id) ;
247
+ let closure_def_id = tcx. hir ( ) . local_def_id_from_hir_id ( closure_id) ;
248
248
249
- tcx. with_freevars ( closure_id , |freevars| {
249
+ tcx. freevars ( closure_def_id ) . iter ( ) . flat_map ( |freevars| {
250
250
freevars
251
251
. iter ( )
252
252
. map ( |freevar| {
253
253
let var_hir_id = freevar. var_id ( ) ;
254
254
let freevar_ty = self . node_ty ( var_hir_id) ;
255
255
let upvar_id = ty:: UpvarId {
256
256
var_path : ty:: UpvarPath { hir_id : var_hir_id } ,
257
- closure_expr_id : LocalDefId :: from_def_id ( closure_def_index ) ,
257
+ closure_expr_id : LocalDefId :: from_def_id ( closure_def_id ) ,
258
258
} ;
259
259
let capture = self . tables . borrow ( ) . upvar_capture ( upvar_id) ;
260
260
@@ -274,8 +274,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
274
274
) ,
275
275
}
276
276
} )
277
- . collect ( )
278
277
} )
278
+ . collect ( )
279
279
}
280
280
}
281
281
0 commit comments