@@ -6,7 +6,7 @@ use cranelift_module::*;
66use rustc_data_structures:: fx:: FxHashSet ;
77use rustc_middle:: middle:: codegen_fn_attrs:: CodegenFnAttrFlags ;
88use rustc_middle:: mir:: interpret:: { AllocId , GlobalAlloc , Scalar , read_target_uint} ;
9- use rustc_middle:: ty:: { Binder , ExistentialTraitRef , ScalarInt } ;
9+ use rustc_middle:: ty:: { ExistentialTraitRef , ScalarInt } ;
1010
1111use crate :: prelude:: * ;
1212
@@ -167,7 +167,9 @@ pub(crate) fn codegen_const_value<'tcx>(
167167 & mut fx. constants_cx ,
168168 fx. module ,
169169 ty,
170- dyn_ty. principal ( ) ,
170+ dyn_ty. principal ( ) . map ( |principal| {
171+ fx. tcx . instantiate_bound_regions_with_erased ( principal)
172+ } ) ,
171173 ) ;
172174 let local_data_id =
173175 fx. module . declare_data_in_func ( data_id, & mut fx. bcx . func ) ;
@@ -243,7 +245,7 @@ pub(crate) fn data_id_for_vtable<'tcx>(
243245 cx : & mut ConstantCx ,
244246 module : & mut dyn Module ,
245247 ty : Ty < ' tcx > ,
246- trait_ref : Option < Binder < ' tcx , ExistentialTraitRef < ' tcx > > > ,
248+ trait_ref : Option < ExistentialTraitRef < ' tcx > > ,
247249) -> DataId {
248250 let alloc_id = tcx. vtable_allocation ( ( ty, trait_ref) ) ;
249251 data_id_for_alloc_id ( cx, module, alloc_id, Mutability :: Not )
@@ -460,9 +462,15 @@ fn define_all_allocs(tcx: TyCtxt<'_>, module: &mut dyn Module, cx: &mut Constant
460462 GlobalAlloc :: Memory ( target_alloc) => {
461463 data_id_for_alloc_id ( cx, module, alloc_id, target_alloc. inner ( ) . mutability )
462464 }
463- GlobalAlloc :: VTable ( ty, dyn_ty) => {
464- data_id_for_vtable ( tcx, cx, module, ty, dyn_ty. principal ( ) )
465- }
465+ GlobalAlloc :: VTable ( ty, dyn_ty) => data_id_for_vtable (
466+ tcx,
467+ cx,
468+ module,
469+ ty,
470+ dyn_ty
471+ . principal ( )
472+ . map ( |principal| tcx. instantiate_bound_regions_with_erased ( principal) ) ,
473+ ) ,
466474 GlobalAlloc :: Static ( def_id) => {
467475 if tcx. codegen_fn_attrs ( def_id) . flags . contains ( CodegenFnAttrFlags :: THREAD_LOCAL )
468476 {
0 commit comments