1
Fork 0

use EarlyBinder in tcx.(try_)subst_mir_and_normalize_erasing_regions

This commit is contained in:
Kyle Matsuda 2023-04-14 09:59:03 -06:00
parent e5d10cdbc3
commit 82f57c16b7
7 changed files with 20 additions and 12 deletions

View file

@ -361,7 +361,7 @@ impl<'tcx> FunctionCx<'_, '_, 'tcx> {
self.instance.subst_mir_and_normalize_erasing_regions( self.instance.subst_mir_and_normalize_erasing_regions(
self.tcx, self.tcx,
ty::ParamEnv::reveal_all(), ty::ParamEnv::reveal_all(),
value, ty::EarlyBinder(value),
) )
} }

View file

@ -111,7 +111,7 @@ impl<'a, 'tcx, Bx: BuilderMethods<'a, 'tcx>> FunctionCx<'a, 'tcx, Bx> {
self.instance.subst_mir_and_normalize_erasing_regions( self.instance.subst_mir_and_normalize_erasing_regions(
self.cx.tcx(), self.cx.tcx(),
ty::ParamEnv::reveal_all(), ty::ParamEnv::reveal_all(),
value, ty::EarlyBinder(value),
) )
} }
} }

View file

@ -495,7 +495,11 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
) -> Result<T, InterpError<'tcx>> { ) -> Result<T, InterpError<'tcx>> {
frame frame
.instance .instance
.try_subst_mir_and_normalize_erasing_regions(*self.tcx, self.param_env, value) .try_subst_mir_and_normalize_erasing_regions(
*self.tcx,
self.param_env,
ty::EarlyBinder(value),
)
.map_err(|_| err_inval!(TooGeneric)) .map_err(|_| err_inval!(TooGeneric))
} }

View file

@ -594,15 +594,15 @@ impl<'tcx> Instance<'tcx> {
&self, &self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
v: T, v: EarlyBinder<T>,
) -> T ) -> T
where where
T: TypeFoldable<TyCtxt<'tcx>> + Clone, T: TypeFoldable<TyCtxt<'tcx>> + Clone,
{ {
if let Some(substs) = self.substs_for_mir_body() { if let Some(substs) = self.substs_for_mir_body() {
tcx.subst_and_normalize_erasing_regions(substs, param_env, ty::EarlyBinder(v)) tcx.subst_and_normalize_erasing_regions(substs, param_env, v)
} else { } else {
tcx.normalize_erasing_regions(param_env, v) tcx.normalize_erasing_regions(param_env, v.subst_identity())
} }
} }
@ -611,15 +611,15 @@ impl<'tcx> Instance<'tcx> {
&self, &self,
tcx: TyCtxt<'tcx>, tcx: TyCtxt<'tcx>,
param_env: ty::ParamEnv<'tcx>, param_env: ty::ParamEnv<'tcx>,
v: T, v: EarlyBinder<T>,
) -> Result<T, NormalizationError<'tcx>> ) -> Result<T, NormalizationError<'tcx>>
where where
T: TypeFoldable<TyCtxt<'tcx>> + Clone, T: TypeFoldable<TyCtxt<'tcx>> + Clone,
{ {
if let Some(substs) = self.substs_for_mir_body() { if let Some(substs) = self.substs_for_mir_body() {
tcx.try_subst_and_normalize_erasing_regions(substs, param_env, ty::EarlyBinder(v)) tcx.try_subst_and_normalize_erasing_regions(substs, param_env, v)
} else { } else {
tcx.try_normalize_erasing_regions(param_env, v) tcx.try_normalize_erasing_regions(param_env, v.subst_identity())
} }
} }

View file

@ -180,7 +180,7 @@ impl<'tcx> Inliner<'tcx> {
let Ok(callee_body) = callsite.callee.try_subst_mir_and_normalize_erasing_regions( let Ok(callee_body) = callsite.callee.try_subst_mir_and_normalize_erasing_regions(
self.tcx, self.tcx,
self.param_env, self.param_env,
callee_body.clone(), ty::EarlyBinder(callee_body.clone()),
) else { ) else {
return Err("failed to normalize callee body"); return Err("failed to normalize callee body");
}; };

View file

@ -44,7 +44,11 @@ pub(crate) fn mir_callgraph_reachable<'tcx>(
) -> bool { ) -> bool {
trace!(%caller); trace!(%caller);
for &(callee, substs) in tcx.mir_inliner_callees(caller.def) { for &(callee, substs) in tcx.mir_inliner_callees(caller.def) {
let Ok(substs) = caller.try_subst_mir_and_normalize_erasing_regions(tcx, param_env, substs) else { let Ok(substs) = caller.try_subst_mir_and_normalize_erasing_regions(
tcx,
param_env,
ty::EarlyBinder(substs),
) else {
trace!(?caller, ?param_env, ?substs, "cannot normalize, skipping"); trace!(?caller, ?param_env, ?substs, "cannot normalize, skipping");
continue; continue;
}; };

View file

@ -677,7 +677,7 @@ impl<'a, 'tcx> MirNeighborCollector<'a, 'tcx> {
self.instance.subst_mir_and_normalize_erasing_regions( self.instance.subst_mir_and_normalize_erasing_regions(
self.tcx, self.tcx,
ty::ParamEnv::reveal_all(), ty::ParamEnv::reveal_all(),
value, ty::EarlyBinder(value),
) )
} }
} }