unify Instance::resolve
This commit is contained in:
parent
e070b45e6a
commit
2666aed498
@ -39,7 +39,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||||||
promoted: Option<mir::Promoted>,
|
promoted: Option<mir::Promoted>,
|
||||||
span: Option<Span>,
|
span: Option<Span>,
|
||||||
) -> ConstEvalResult<'tcx> {
|
) -> ConstEvalResult<'tcx> {
|
||||||
match ty::Instance::resolve_const_arg(self, param_env, def, substs) {
|
match ty::Instance::resolve_opt_const_arg(self, param_env, def, substs) {
|
||||||
Ok(Some(instance)) => {
|
Ok(Some(instance)) => {
|
||||||
let cid = GlobalId { instance, promoted };
|
let cid = GlobalId { instance, promoted };
|
||||||
self.const_eval_global_id(param_env, cid, span)
|
self.const_eval_global_id(param_env, cid, span)
|
||||||
|
@ -338,6 +338,21 @@ impl<'tcx> Instance<'tcx> {
|
|||||||
param_env: ty::ParamEnv<'tcx>,
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
def_id: DefId,
|
def_id: DefId,
|
||||||
substs: SubstsRef<'tcx>,
|
substs: SubstsRef<'tcx>,
|
||||||
|
) -> Result<Option<Instance<'tcx>>, ErrorReported> {
|
||||||
|
Instance::resolve_opt_const_arg(
|
||||||
|
tcx,
|
||||||
|
param_env,
|
||||||
|
ty::WithOptConstParam::unknown(def_id),
|
||||||
|
substs,
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
// This should be kept up to date with `resolve`.
|
||||||
|
pub fn resolve_opt_const_arg(
|
||||||
|
tcx: TyCtxt<'tcx>,
|
||||||
|
param_env: ty::ParamEnv<'tcx>,
|
||||||
|
def: ty::WithOptConstParam<DefId>,
|
||||||
|
substs: SubstsRef<'tcx>,
|
||||||
) -> Result<Option<Instance<'tcx>>, ErrorReported> {
|
) -> Result<Option<Instance<'tcx>>, ErrorReported> {
|
||||||
// All regions in the result of this query are erased, so it's
|
// All regions in the result of this query are erased, so it's
|
||||||
// fine to erase all of the input regions.
|
// fine to erase all of the input regions.
|
||||||
@ -348,18 +363,6 @@ impl<'tcx> Instance<'tcx> {
|
|||||||
let substs = tcx.erase_regions(&substs);
|
let substs = tcx.erase_regions(&substs);
|
||||||
|
|
||||||
// FIXME(eddyb) should this always use `param_env.with_reveal_all()`?
|
// FIXME(eddyb) should this always use `param_env.with_reveal_all()`?
|
||||||
tcx.resolve_instance(tcx.erase_regions(¶m_env.and((def_id, substs))))
|
|
||||||
}
|
|
||||||
|
|
||||||
// This should be kept up to date with `resolve`.
|
|
||||||
pub fn resolve_const_arg(
|
|
||||||
tcx: TyCtxt<'tcx>,
|
|
||||||
param_env: ty::ParamEnv<'tcx>,
|
|
||||||
def: ty::WithOptConstParam<DefId>,
|
|
||||||
substs: SubstsRef<'tcx>,
|
|
||||||
) -> Result<Option<Instance<'tcx>>, ErrorReported> {
|
|
||||||
let substs = tcx.erase_regions(&substs);
|
|
||||||
|
|
||||||
if let Some((did, param_did)) = def.as_const_arg() {
|
if let Some((did, param_did)) = def.as_const_arg() {
|
||||||
tcx.resolve_instance_of_const_arg(
|
tcx.resolve_instance_of_const_arg(
|
||||||
tcx.erase_regions(¶m_env.and((did, param_did, substs))),
|
tcx.erase_regions(¶m_env.and((did, param_did, substs))),
|
||||||
|
Loading…
Reference in New Issue
Block a user