erase all lifetimes from function types before creating pointers to them
This commit is contained in:
parent
e2091ff934
commit
1549c2d51e
@ -654,6 +654,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
|
||||
ReifyFnPointer => match self.operand_ty(operand).sty {
|
||||
ty::TyFnDef(def_id, substs, fn_ty) => {
|
||||
let fn_ty = self.tcx.erase_regions(&fn_ty);
|
||||
let fn_ptr = self.memory.create_fn_ptr(def_id, substs, fn_ty);
|
||||
self.write_value(Value::ByVal(PrimVal::from_fn_ptr(fn_ptr)), dest, dest_ty)?;
|
||||
},
|
||||
@ -665,6 +666,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
let src = self.eval_operand(operand)?;
|
||||
let ptr = src.read_ptr(&self.memory)?;
|
||||
let (def_id, substs, _) = self.memory.get_fn(ptr.alloc_id)?;
|
||||
let unsafe_fn_ty = self.tcx.erase_regions(&unsafe_fn_ty);
|
||||
let fn_ptr = self.memory.create_fn_ptr(def_id, substs, unsafe_fn_ty);
|
||||
self.write_value(Value::ByVal(PrimVal::from_fn_ptr(fn_ptr)), dest, dest_ty)?;
|
||||
},
|
||||
@ -1390,6 +1392,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
ty::TyFloat(FloatTy::F64) => PrimVal::from_f64(self.memory.read_f64(ptr)?),
|
||||
|
||||
ty::TyFnDef(def_id, substs, fn_ty) => {
|
||||
let fn_ty = self.tcx.erase_regions(&fn_ty);
|
||||
PrimVal::from_fn_ptr(self.memory.create_fn_ptr(def_id, substs, fn_ty))
|
||||
},
|
||||
ty::TyFnPtr(_) => self.memory.read_ptr(ptr).map(PrimVal::from_fn_ptr)?,
|
||||
|
@ -35,7 +35,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
self.get_vtable_methods(id, substs)
|
||||
.into_iter()
|
||||
.map(|opt_mth| opt_mth.map(|mth| {
|
||||
self.memory.create_fn_ptr(mth.method.def_id, mth.substs, mth.method.fty)
|
||||
let fn_ty = self.tcx.erase_regions(&mth.method.fty);
|
||||
self.memory.create_fn_ptr(mth.method.def_id, mth.substs, fn_ty)
|
||||
}))
|
||||
.collect::<Vec<_>>()
|
||||
.into_iter()
|
||||
@ -90,7 +91,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> {
|
||||
if let Some(drop_def_id) = adt_def.destructor() {
|
||||
let ty_scheme = self.tcx.lookup_item_type(drop_def_id);
|
||||
let fn_ty = match ty_scheme.ty.sty {
|
||||
ty::TyFnDef(_, _, fn_ty) => fn_ty,
|
||||
ty::TyFnDef(_, _, fn_ty) => self.tcx.erase_regions(&fn_ty),
|
||||
_ => bug!("drop method is not a TyFnDef"),
|
||||
};
|
||||
let fn_ptr = self.memory.create_fn_ptr(drop_def_id, substs, fn_ty);
|
||||
|
Loading…
x
Reference in New Issue
Block a user