@@ -13,7 +13,7 @@ use rustc_data_structures::sorted_map::SortedIndexMultiMap;
13
13
use rustc_errors:: ErrorGuaranteed ;
14
14
use rustc_hir:: def:: DefKind ;
15
15
use rustc_hir:: def_id:: { DefId , LocalDefId } ;
16
- use rustc_hir:: { self as hir, BindingMode , ByRef , HirId , Node } ;
16
+ use rustc_hir:: { self as hir, BindingMode , ByRef , HirId , ItemLocalId , Node } ;
17
17
use rustc_index:: bit_set:: GrowableBitSet ;
18
18
use rustc_index:: { Idx , IndexSlice , IndexVec } ;
19
19
use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
@@ -221,7 +221,7 @@ struct Builder<'a, 'tcx> {
221
221
coverage_info : Option < coverageinfo:: CoverageInfoBuilder > ,
222
222
}
223
223
224
- type CaptureMap < ' tcx > = SortedIndexMultiMap < usize , HirId , Capture < ' tcx > > ;
224
+ type CaptureMap < ' tcx > = SortedIndexMultiMap < usize , ItemLocalId , Capture < ' tcx > > ;
225
225
226
226
#[ derive( Debug ) ]
227
227
struct Capture < ' tcx > {
@@ -853,6 +853,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
853
853
let capture_tys = upvar_args. upvar_tys ( ) ;
854
854
855
855
let tcx = self . tcx ;
856
+ let mut upvar_owner = None ;
856
857
self . upvars = tcx
857
858
. closure_captures ( self . def_id )
858
859
. iter ( )
@@ -866,6 +867,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
866
867
HirPlaceBase :: Upvar ( upvar_id) => upvar_id. var_path . hir_id ,
867
868
_ => bug ! ( "Expected an upvar" ) ,
868
869
} ;
870
+ let upvar_base = upvar_owner. get_or_insert ( var_id. owner ) ;
871
+ assert_eq ! ( * upvar_base, var_id. owner) ;
872
+ let var_id = var_id. local_id ;
869
873
870
874
let mutability = captured_place. mutability ;
871
875
0 commit comments