make subst_mir take EarlyBinder
This commit is contained in:
parent
82f57c16b7
commit
e4f6b8b43b
@ -578,14 +578,15 @@ fn substs_for_mir_body(&self) -> Option<SubstsRef<'tcx>> {
|
||||
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
|
||||
T: TypeFoldable<TyCtxt<'tcx>> + Copy,
|
||||
{
|
||||
let v = v.map_bound(|v| *v);
|
||||
if let Some(substs) = self.substs_for_mir_body() {
|
||||
EarlyBinder(*v).subst(tcx, substs)
|
||||
v.subst(tcx, substs)
|
||||
} else {
|
||||
*v
|
||||
v.subst_identity()
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -444,7 +444,9 @@ fn check_mir_body(
|
||||
work_list.push(target);
|
||||
|
||||
// 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 {
|
||||
work_list.push(unwind);
|
||||
}
|
||||
@ -788,7 +790,9 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
match terminator.kind {
|
||||
TerminatorKind::Drop { ref place, unwind, .. } => {
|
||||
// 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) {
|
||||
self.cost += CALL_PENALTY;
|
||||
if let UnwindAction::Cleanup(_) = unwind {
|
||||
@ -799,7 +803,7 @@ fn visit_terminator(&mut self, terminator: &Terminator<'tcx>, location: Location
|
||||
}
|
||||
}
|
||||
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) {
|
||||
// Don't give intrinsics the extra penalty for calls
|
||||
INSTR_COST
|
||||
|
Loading…
Reference in New Issue
Block a user