@@ -121,9 +121,9 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
121121 None
122122 } ;
123123
124- self . tcx . with_freevars ( closure_hir_id , | freevars| {
124+ if let Some ( freevars ) = self . tcx . freevars ( closure_def_id ) {
125125 let mut freevar_list: Vec < ty:: UpvarId > = Vec :: with_capacity ( freevars. len ( ) ) ;
126- for freevar in freevars {
126+ for freevar in freevars. iter ( ) {
127127 let upvar_id = ty:: UpvarId {
128128 var_path : ty:: UpvarPath {
129129 hir_id : freevar. var_id ( ) ,
@@ -155,14 +155,14 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
155155 }
156156 // Add the vector of freevars to the map keyed with the closure id.
157157 // This gives us an easier access to them without having to call
158- // with_freevars again..
158+ // tcx.freevars again..
159159 if !freevar_list. is_empty ( ) {
160160 self . tables
161161 . borrow_mut ( )
162162 . upvar_list
163163 . insert ( closure_def_id, freevar_list) ;
164164 }
165- } ) ;
165+ }
166166
167167 let body_owner_def_id = self . tcx . hir ( ) . body_owner_def_id ( body. id ( ) ) ;
168168 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> {
244244 // This may change if abstract return types of some sort are
245245 // implemented.
246246 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) ;
248248
249- tcx. with_freevars ( closure_id , |freevars| {
249+ tcx. freevars ( closure_def_id ) . iter ( ) . flat_map ( |freevars| {
250250 freevars
251251 . iter ( )
252252 . map ( |freevar| {
253253 let var_hir_id = freevar. var_id ( ) ;
254254 let freevar_ty = self . node_ty ( var_hir_id) ;
255255 let upvar_id = ty:: UpvarId {
256256 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 ) ,
258258 } ;
259259 let capture = self . tables . borrow ( ) . upvar_capture ( upvar_id) ;
260260
@@ -274,8 +274,8 @@ impl<'a, 'gcx, 'tcx> FnCtxt<'a, 'gcx, 'tcx> {
274274 ) ,
275275 }
276276 } )
277- . collect ( )
278277 } )
278+ . collect ( )
279279 }
280280}
281281
0 commit comments