Auto merge of #74040 - lcnr:const-occurs-check, r=nikomatsakis
fix unification of const variables
r? `@nikomatsakis` `@varkor` `@eddyb` let's just ping everyone here 😅
This commit is contained in:
commit
e0bf356f9e
18 changed files with 452 additions and 19 deletions
|
@ -482,13 +482,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
/// The `substs` are assumed to already be in our interpreter "universe" (param_env).
|
||||
pub(super) fn resolve(
|
||||
&self,
|
||||
def_id: DefId,
|
||||
def: ty::WithOptConstParam<DefId>,
|
||||
substs: SubstsRef<'tcx>,
|
||||
) -> InterpResult<'tcx, ty::Instance<'tcx>> {
|
||||
trace!("resolve: {:?}, {:#?}", def_id, substs);
|
||||
trace!("resolve: {:?}, {:#?}", def, substs);
|
||||
trace!("param_env: {:#?}", self.param_env);
|
||||
trace!("substs: {:#?}", substs);
|
||||
match ty::Instance::resolve(*self.tcx, self.param_env, def_id, substs) {
|
||||
match ty::Instance::resolve_opt_const_arg(*self.tcx, self.param_env, def, substs) {
|
||||
Ok(Some(instance)) => Ok(instance),
|
||||
Ok(None) => throw_inval!(TooGeneric),
|
||||
|
||||
|
|
|
@ -552,7 +552,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
ty::ConstKind::Param(_) => throw_inval!(TooGeneric),
|
||||
ty::ConstKind::Error(_) => throw_inval!(TypeckError(ErrorReported)),
|
||||
ty::ConstKind::Unevaluated(def, substs, promoted) => {
|
||||
let instance = self.resolve(def.did, substs)?;
|
||||
let instance = self.resolve(def, substs)?;
|
||||
return Ok(self.eval_to_allocation(GlobalId { instance, promoted })?.into());
|
||||
}
|
||||
ty::ConstKind::Infer(..)
|
||||
|
|
|
@ -64,7 +64,12 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
|
|||
}
|
||||
ty::FnDef(def_id, substs) => {
|
||||
let sig = func.layout.ty.fn_sig(*self.tcx);
|
||||
(FnVal::Instance(self.resolve(def_id, substs)?), sig.abi())
|
||||
(
|
||||
FnVal::Instance(
|
||||
self.resolve(ty::WithOptConstParam::unknown(def_id), substs)?,
|
||||
),
|
||||
sig.abi(),
|
||||
)
|
||||
}
|
||||
_ => span_bug!(
|
||||
terminator.source_info.span,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue