@@ -9,6 +9,7 @@ use rustc_hir::{HirId, Node};
99use rustc_index:: bit_set:: BitSet ;
1010use rustc_index:: vec:: IndexVec ;
1111use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
12+ use rustc_middle:: hir:: place:: PlaceBase as HirPlaceBase ;
1213use rustc_middle:: mir:: {
1314 traversal, Body , ClearCrossCrate , Local , Location , Mutability , Operand , Place , PlaceElem ,
1415 PlaceRef ,
@@ -75,6 +76,7 @@ crate use region_infer::RegionInferenceContext;
7576crate struct Upvar {
7677 name : Symbol ,
7778
79+ // FIXME(project-rfc-2229#8): This should use Place or something similar
7880 var_hir_id : HirId ,
7981
8082 /// If true, the capture is behind a reference.
@@ -155,13 +157,13 @@ fn do_mir_borrowck<'a, 'tcx>(
155157 infcx. set_tainted_by_errors ( ) ;
156158 }
157159 let upvars: Vec < _ > = tables
158- . closure_captures
159- . get ( & def . did . to_def_id ( ) )
160- . into_iter ( )
161- . flat_map ( |v| v . values ( ) )
162- . map ( |upvar_id| {
163- let var_hir_id = upvar_id . var_path . hir_id ;
164- let capture = tables . upvar_capture ( * upvar_id ) ;
160+ . closure_min_captures_flattened ( def . did . to_def_id ( ) )
161+ . map ( |captured_place| {
162+ let var_hir_id = match captured_place . place . base {
163+ HirPlaceBase :: Upvar ( upvar_id ) => upvar_id . var_path . hir_id ,
164+ _ => bug ! ( "Expected upvar" ) ,
165+ } ;
166+ let capture = captured_place . info . capture_kind ;
165167 let by_ref = match capture {
166168 ty:: UpvarCapture :: ByValue ( _) => false ,
167169 ty:: UpvarCapture :: ByRef ( ..) => true ,
0 commit comments