Also fix first_method_vtable_slot
This commit is contained in:
parent
d87e0ca497
commit
7c552d56b2
1 changed files with 12 additions and 13 deletions
|
@ -332,14 +332,10 @@ pub(crate) fn first_method_vtable_slot<'tcx>(tcx: TyCtxt<'tcx>, key: ty::TraitRe
|
||||||
let ty::Dynamic(source, _, _) = *key.self_ty().kind() else {
|
let ty::Dynamic(source, _, _) = *key.self_ty().kind() else {
|
||||||
bug!();
|
bug!();
|
||||||
};
|
};
|
||||||
let source_principal = tcx
|
let source_principal =
|
||||||
.normalize_erasing_regions(ty::ParamEnv::reveal_all(), source.principal().unwrap())
|
source.principal().unwrap().with_self_ty(tcx, tcx.types.trait_object_dummy_self);
|
||||||
.with_self_ty(tcx, tcx.types.trait_object_dummy_self);
|
|
||||||
|
|
||||||
let target_principal = tcx
|
let target_principal = ty::Binder::dummy(ty::ExistentialTraitRef::erase_self_ty(tcx, key));
|
||||||
.normalize_erasing_regions(ty::ParamEnv::reveal_all(), key)
|
|
||||||
// We don't care about the self type, since it will always be the same thing.
|
|
||||||
.with_self_ty(tcx, tcx.types.trait_object_dummy_self);
|
|
||||||
|
|
||||||
let vtable_segment_callback = {
|
let vtable_segment_callback = {
|
||||||
let mut vptr_offset = 0;
|
let mut vptr_offset = 0;
|
||||||
|
@ -348,15 +344,18 @@ pub(crate) fn first_method_vtable_slot<'tcx>(tcx: TyCtxt<'tcx>, key: ty::TraitRe
|
||||||
VtblSegment::MetadataDSA => {
|
VtblSegment::MetadataDSA => {
|
||||||
vptr_offset += TyCtxt::COMMON_VTABLE_ENTRIES.len();
|
vptr_offset += TyCtxt::COMMON_VTABLE_ENTRIES.len();
|
||||||
}
|
}
|
||||||
VtblSegment::TraitOwnEntries { trait_ref, emit_vptr } => {
|
VtblSegment::TraitOwnEntries { trait_ref: vtable_principal, emit_vptr } => {
|
||||||
if tcx
|
if trait_refs_are_compatible(
|
||||||
.normalize_erasing_late_bound_regions(ty::ParamEnv::reveal_all(), trait_ref)
|
tcx,
|
||||||
== target_principal
|
vtable_principal
|
||||||
{
|
.map_bound(|t| ty::ExistentialTraitRef::erase_self_ty(tcx, t)),
|
||||||
|
target_principal,
|
||||||
|
) {
|
||||||
return ControlFlow::Break(vptr_offset);
|
return ControlFlow::Break(vptr_offset);
|
||||||
}
|
}
|
||||||
|
|
||||||
vptr_offset += tcx.own_existential_vtable_entries(trait_ref.def_id()).len();
|
vptr_offset +=
|
||||||
|
tcx.own_existential_vtable_entries(vtable_principal.def_id()).len();
|
||||||
|
|
||||||
if emit_vptr {
|
if emit_vptr {
|
||||||
vptr_offset += 1;
|
vptr_offset += 1;
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue