make subst_mir take EarlyBinder
This commit is contained in:
parent
82f57c16b7
commit
e4f6b8b43b
2 changed files with 11 additions and 6 deletions
|
@ -578,14 +578,15 @@ impl<'tcx> Instance<'tcx> {
|
||||||
self.def.has_polymorphic_mir_body().then_some(self.substs)
|
self.def.has_polymorphic_mir_body().then_some(self.substs)
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn subst_mir<T>(&self, tcx: TyCtxt<'tcx>, v: &T) -> T
|
pub fn subst_mir<T>(&self, tcx: TyCtxt<'tcx>, v: EarlyBinder<&T>) -> T
|
||||||
where
|
where
|
||||||
T: TypeFoldable<TyCtxt<'tcx>> + Copy,
|
T: TypeFoldable<TyCtxt<'tcx>> + Copy,
|
||||||
{
|
{
|
||||||
|
let v = v.map_bound(|v| *v);
|
||||||
if let Some(substs) = self.substs_for_mir_body() {
|
if let Some(substs) = self.substs_for_mir_body() {
|
||||||
EarlyBinder(*v).subst(tcx, substs)
|
v.subst(tcx, substs)
|
||||||
} else {
|
} else {
|
||||||
*v
|
v.subst_identity()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -444,7 +444,9 @@ impl<'tcx> Inliner<'tcx> {
|
||||||
work_list.push(target);
|
work_list.push(target);
|
||||||
|
|
||||||
// If the place doesn't actually need dropping, treat it like a regular goto.
|
// If the place doesn't actually need dropping, treat it like a regular goto.
|
||||||
let ty = callsite.callee.subst_mir(self.tcx, &place.ty(callee_body, tcx).ty);
|
let ty = callsite
|
||||||
|
.callee
|
||||||
|
.subst_mir(self.tcx, ty::EarlyBinder(&place.ty(callee_body, tcx).ty));
|
||||||
if ty.needs_drop(tcx, self.param_env) && let UnwindAction::Cleanup(unwind) = unwind {
|
if ty.needs_drop(tcx, self.param_env) && let UnwindAction::Cleanup(unwind) = unwind {
|
||||||
work_list.push(unwind);
|
work_list.push(unwind);
|
||||||
}
|
}
|
||||||
|
@ -788,7 +790,9 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> {
|
||||||
match terminator.kind {
|
match terminator.kind {
|
||||||
TerminatorKind::Drop { ref place, unwind, .. } => {
|
TerminatorKind::Drop { ref place, unwind, .. } => {
|
||||||
// If the place doesn't actually need dropping, treat it like a regular goto.
|
// If the place doesn't actually need dropping, treat it like a regular goto.
|
||||||
let ty = self.instance.subst_mir(tcx, &place.ty(self.callee_body, tcx).ty);
|
let ty = self
|
||||||
|
.instance
|
||||||
|
.subst_mir(tcx, ty::EarlyBinder(&place.ty(self.callee_body, tcx).ty));
|
||||||
if ty.needs_drop(tcx, self.param_env) {
|
if ty.needs_drop(tcx, self.param_env) {
|
||||||
self.cost += CALL_PENALTY;
|
self.cost += CALL_PENALTY;
|
||||||
if let UnwindAction::Cleanup(_) = unwind {
|
if let UnwindAction::Cleanup(_) = unwind {
|
||||||
|
@ -799,7 +803,7 @@ impl<'tcx> Visitor<'tcx> for CostChecker<'_, 'tcx> {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
TerminatorKind::Call { func: Operand::Constant(ref f), unwind, .. } => {
|
TerminatorKind::Call { func: Operand::Constant(ref f), unwind, .. } => {
|
||||||
let fn_ty = self.instance.subst_mir(tcx, &f.literal.ty());
|
let fn_ty = self.instance.subst_mir(tcx, ty::EarlyBinder(&f.literal.ty()));
|
||||||
self.cost += if let ty::FnDef(def_id, _) = *fn_ty.kind() && tcx.is_intrinsic(def_id) {
|
self.cost += if let ty::FnDef(def_id, _) = *fn_ty.kind() && tcx.is_intrinsic(def_id) {
|
||||||
// Don't give intrinsics the extra penalty for calls
|
// Don't give intrinsics the extra penalty for calls
|
||||||
INSTR_COST
|
INSTR_COST
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue