diff --git a/src/librustc_middle/mir/interpret/queries.rs b/src/librustc_middle/mir/interpret/queries.rs index 0a9c2ac9475..d7c0be05859 100644 --- a/src/librustc_middle/mir/interpret/queries.rs +++ b/src/librustc_middle/mir/interpret/queries.rs @@ -39,7 +39,7 @@ impl<'tcx> TyCtxt<'tcx> { promoted: Option, span: Option, ) -> 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)) => { let cid = GlobalId { instance, promoted }; self.const_eval_global_id(param_env, cid, span) diff --git a/src/librustc_middle/ty/instance.rs b/src/librustc_middle/ty/instance.rs index 1a5c7fe4859..f627d05d3e9 100644 --- a/src/librustc_middle/ty/instance.rs +++ b/src/librustc_middle/ty/instance.rs @@ -338,6 +338,21 @@ impl<'tcx> Instance<'tcx> { param_env: ty::ParamEnv<'tcx>, def_id: DefId, substs: SubstsRef<'tcx>, + ) -> Result>, 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, + substs: SubstsRef<'tcx>, ) -> Result>, ErrorReported> { // All regions in the result of this query are erased, so it's // fine to erase all of the input regions. @@ -348,18 +363,6 @@ impl<'tcx> Instance<'tcx> { let substs = tcx.erase_regions(&substs); // 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, - substs: SubstsRef<'tcx>, - ) -> Result>, ErrorReported> { - let substs = tcx.erase_regions(&substs); - if let Some((did, param_did)) = def.as_const_arg() { tcx.resolve_instance_of_const_arg( tcx.erase_regions(¶m_env.and((did, param_did, substs))),