Skip to content

Commit 3924540

Browse files
committed
fix InterpCx resolve
1 parent a409a23 commit 3924540

File tree

3 files changed

+10
-5
lines changed

3 files changed

+10
-5
lines changed

compiler/rustc_mir/src/interpret/eval_context.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -482,13 +482,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
482482
/// The `substs` are assumed to already be in our interpreter "universe" (param_env).
483483
pub(super) fn resolve(
484484
&self,
485-
def_id: DefId,
485+
def: ty::WithOptConstParam<DefId>,
486486
substs: SubstsRef<'tcx>,
487487
) -> InterpResult<'tcx, ty::Instance<'tcx>> {
488-
trace!("resolve: {:?}, {:#?}", def_id, substs);
488+
trace!("resolve: {:?}, {:#?}", def, substs);
489489
trace!("param_env: {:#?}", self.param_env);
490490
trace!("substs: {:#?}", substs);
491-
match ty::Instance::resolve(*self.tcx, self.param_env, def_id, substs) {
491+
match ty::Instance::resolve_opt_const_arg(*self.tcx, self.param_env, def, substs) {
492492
Ok(Some(instance)) => Ok(instance),
493493
Ok(None) => throw_inval!(TooGeneric),
494494

compiler/rustc_mir/src/interpret/operand.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -552,7 +552,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
552552
ty::ConstKind::Param(_) => throw_inval!(TooGeneric),
553553
ty::ConstKind::Error(_) => throw_inval!(TypeckError(ErrorReported)),
554554
ty::ConstKind::Unevaluated(def, substs, promoted) => {
555-
let instance = self.resolve(def.did, substs)?;
555+
let instance = self.resolve(def, substs)?;
556556
return Ok(self.eval_to_allocation(GlobalId { instance, promoted })?.into());
557557
}
558558
ty::ConstKind::Infer(..)

compiler/rustc_mir/src/interpret/terminator.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
6464
}
6565
ty::FnDef(def_id, substs) => {
6666
let sig = func.layout.ty.fn_sig(*self.tcx);
67-
(FnVal::Instance(self.resolve(def_id, substs)?), sig.abi())
67+
(
68+
FnVal::Instance(
69+
self.resolve(ty::WithOptConstParam::unknown(def_id), substs)?,
70+
),
71+
sig.abi(),
72+
)
6873
}
6974
_ => span_bug!(
7075
terminator.source_info.span,

0 commit comments

Comments
 (0)