@@ -9,6 +9,7 @@ use rustc_hir::{HirId, Node};
9
9
use rustc_index:: bit_set:: BitSet ;
10
10
use rustc_index:: vec:: IndexVec ;
11
11
use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
12
+ use rustc_middle:: hir:: place:: PlaceBase as HirPlaceBase ;
12
13
use rustc_middle:: mir:: {
13
14
traversal, Body , ClearCrossCrate , Local , Location , Mutability , Operand , Place , PlaceElem ,
14
15
PlaceRef ,
@@ -75,6 +76,7 @@ crate use region_infer::RegionInferenceContext;
75
76
crate struct Upvar {
76
77
name : Symbol ,
77
78
79
+ // FIXME(project-rfc-2229#8): This should use Place or something similar
78
80
var_hir_id : HirId ,
79
81
80
82
/// If true, the capture is behind a reference.
@@ -155,13 +157,13 @@ fn do_mir_borrowck<'a, 'tcx>(
155
157
infcx. set_tainted_by_errors ( ) ;
156
158
}
157
159
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 ;
165
167
let by_ref = match capture {
166
168
ty:: UpvarCapture :: ByValue ( _) => false ,
167
169
ty:: UpvarCapture :: ByRef ( ..) => true ,
0 commit comments