subst -> instantiate
This commit is contained in:
parent
af68593179
commit
3c52a3e280
25 changed files with 66 additions and 75 deletions
|
@ -118,7 +118,7 @@ impl<'tcx> Instance<'tcx> {
|
|||
/// lifetimes erased, allowing a `ParamEnv` to be specified for use during normalization.
|
||||
pub fn ty(&self, tcx: TyCtxt<'tcx>, param_env: ty::ParamEnv<'tcx>) -> Ty<'tcx> {
|
||||
let ty = tcx.type_of(self.def.def_id());
|
||||
tcx.subst_and_normalize_erasing_regions(self.args, param_env, ty)
|
||||
tcx.instantiate_and_normalize_erasing_regions(self.args, param_env, ty)
|
||||
}
|
||||
|
||||
/// Finds a crate that contains a monomorphization of this instance that
|
||||
|
@ -580,7 +580,7 @@ impl<'tcx> Instance<'tcx> {
|
|||
self.def.has_polymorphic_mir_body().then_some(self.args)
|
||||
}
|
||||
|
||||
pub fn subst_mir<T>(&self, tcx: TyCtxt<'tcx>, v: EarlyBinder<&T>) -> T
|
||||
pub fn instantiate_mir<T>(&self, tcx: TyCtxt<'tcx>, v: EarlyBinder<&T>) -> T
|
||||
where
|
||||
T: TypeFoldable<TyCtxt<'tcx>> + Copy,
|
||||
{
|
||||
|
@ -593,7 +593,7 @@ impl<'tcx> Instance<'tcx> {
|
|||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn subst_mir_and_normalize_erasing_regions<T>(
|
||||
pub fn instantiate_mir_and_normalize_erasing_regions<T>(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -603,14 +603,14 @@ impl<'tcx> Instance<'tcx> {
|
|||
T: TypeFoldable<TyCtxt<'tcx>> + Clone,
|
||||
{
|
||||
if let Some(args) = self.args_for_mir_body() {
|
||||
tcx.subst_and_normalize_erasing_regions(args, param_env, v)
|
||||
tcx.instantiate_and_normalize_erasing_regions(args, param_env, v)
|
||||
} else {
|
||||
tcx.normalize_erasing_regions(param_env, v.skip_binder())
|
||||
}
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
pub fn try_subst_mir_and_normalize_erasing_regions<T>(
|
||||
pub fn try_instantiate_mir_and_normalize_erasing_regions<T>(
|
||||
&self,
|
||||
tcx: TyCtxt<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -620,7 +620,7 @@ impl<'tcx> Instance<'tcx> {
|
|||
T: TypeFoldable<TyCtxt<'tcx>> + Clone,
|
||||
{
|
||||
if let Some(args) = self.args_for_mir_body() {
|
||||
tcx.try_subst_and_normalize_erasing_regions(args, param_env, v)
|
||||
tcx.try_instantiate_and_normalize_erasing_regions(args, param_env, v)
|
||||
} else {
|
||||
tcx.try_normalize_erasing_regions(param_env, v.skip_binder())
|
||||
}
|
||||
|
|
|
@ -134,8 +134,9 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
/// in-scope substitutions and then normalizing any associated
|
||||
/// types.
|
||||
/// Panics if normalization fails. In case normalization might fail
|
||||
/// use `try_subst_and_normalize_erasing_regions` instead.
|
||||
pub fn subst_and_normalize_erasing_regions<T>(
|
||||
/// use `try_instantiate_and_normalize_erasing_regions` instead.
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
pub fn instantiate_and_normalize_erasing_regions<T>(
|
||||
self,
|
||||
param_args: GenericArgsRef<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -144,22 +145,16 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
where
|
||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||
{
|
||||
debug!(
|
||||
"subst_and_normalize_erasing_regions(\
|
||||
param_args={:?}, \
|
||||
value={:?}, \
|
||||
param_env={:?})",
|
||||
param_args, value, param_env,
|
||||
);
|
||||
let substituted = value.instantiate(self, param_args);
|
||||
self.normalize_erasing_regions(param_env, substituted)
|
||||
}
|
||||
|
||||
/// Monomorphizes a type from the AST by first applying the
|
||||
/// in-scope substitutions and then trying to normalize any associated
|
||||
/// types. Contrary to `subst_and_normalize_erasing_regions` this does
|
||||
/// types. Contrary to `instantiate_and_normalize_erasing_regions` this does
|
||||
/// not assume that normalization succeeds.
|
||||
pub fn try_subst_and_normalize_erasing_regions<T>(
|
||||
#[instrument(level = "debug", skip(self))]
|
||||
pub fn try_instantiate_and_normalize_erasing_regions<T>(
|
||||
self,
|
||||
param_args: GenericArgsRef<'tcx>,
|
||||
param_env: ty::ParamEnv<'tcx>,
|
||||
|
@ -168,13 +163,6 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
where
|
||||
T: TypeFoldable<TyCtxt<'tcx>>,
|
||||
{
|
||||
debug!(
|
||||
"subst_and_normalize_erasing_regions(\
|
||||
param_args={:?}, \
|
||||
value={:?}, \
|
||||
param_env={:?})",
|
||||
param_args, value, param_env,
|
||||
);
|
||||
let substituted = value.instantiate(self, param_args);
|
||||
self.try_normalize_erasing_regions(param_env, substituted)
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue