@@ -13,7 +13,7 @@ use rustc_data_structures::sorted_map::SortedIndexMultiMap;
1313use rustc_errors:: ErrorGuaranteed ;
1414use rustc_hir:: def:: DefKind ;
1515use 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 } ;
1717use rustc_index:: bit_set:: GrowableBitSet ;
1818use rustc_index:: { Idx , IndexSlice , IndexVec } ;
1919use rustc_infer:: infer:: { InferCtxt , TyCtxtInferExt } ;
@@ -221,7 +221,7 @@ struct Builder<'a, 'tcx> {
221221 coverage_info : Option < coverageinfo:: CoverageInfoBuilder > ,
222222}
223223
224- type CaptureMap < ' tcx > = SortedIndexMultiMap < usize , HirId , Capture < ' tcx > > ;
224+ type CaptureMap < ' tcx > = SortedIndexMultiMap < usize , ItemLocalId , Capture < ' tcx > > ;
225225
226226#[ derive( Debug ) ]
227227struct Capture < ' tcx > {
@@ -853,6 +853,7 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
853853 let capture_tys = upvar_args. upvar_tys ( ) ;
854854
855855 let tcx = self . tcx ;
856+ let mut upvar_owner = None ;
856857 self . upvars = tcx
857858 . closure_captures ( self . def_id )
858859 . iter ( )
@@ -866,6 +867,9 @@ impl<'a, 'tcx> Builder<'a, 'tcx> {
866867 HirPlaceBase :: Upvar ( upvar_id) => upvar_id. var_path . hir_id ,
867868 _ => bug ! ( "Expected an upvar" ) ,
868869 } ;
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 ;
869873
870874 let mutability = captured_place. mutability ;
871875
0 commit comments