1
Fork 0

Resolve to Instance::VtableShim when necessary.

This commit is contained in:
Masaki Hara 2018-09-11 23:30:55 +09:00
parent 250979c0ae
commit f2ef005d1d
3 changed files with 18 additions and 2 deletions

View file

@ -220,3 +220,19 @@ pub fn resolve_and_get_fn(
).unwrap()
)
}
pub fn resolve_and_get_fn_for_vtable(
cx: &CodegenCx<'ll, 'tcx>,
def_id: DefId,
substs: &'tcx Substs<'tcx>,
) -> &'ll Value {
get_fn(
cx,
ty::Instance::resolve_for_vtable(
cx.tcx,
ty::ParamEnv::reveal_all(),
def_id,
substs
).unwrap()
)
}

View file

@ -89,7 +89,7 @@ pub fn get_vtable(
let methods = tcx.vtable_methods(trait_ref.with_self_ty(tcx, ty));
let methods = methods.iter().cloned().map(|opt_mth| {
opt_mth.map_or(nullptr, |(def_id, substs)| {
callee::resolve_and_get_fn(cx, def_id, substs)
callee::resolve_and_get_fn_for_vtable(cx, def_id, substs)
})
});

View file

@ -915,7 +915,7 @@ fn create_mono_items_for_vtable_methods<'a, 'tcx>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
// Walk all methods of the trait, including those of its supertraits
let methods = tcx.vtable_methods(poly_trait_ref);
let methods = methods.iter().cloned().filter_map(|method| method)
.map(|(def_id, substs)| ty::Instance::resolve(
.map(|(def_id, substs)| ty::Instance::resolve_for_vtable(
tcx,
ty::ParamEnv::reveal_all(),
def_id,