Trait rustc_infer::infer::canonical::substitute::CanonicalExt
source · pub(super) trait CanonicalExt<'tcx, V> {
fn substitute(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>
) -> V
where
V: TypeFoldable<'tcx>;
fn substitute_projected<T>(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>,
projection_fn: impl FnOnce(&V) -> T
) -> T
where
T: TypeFoldable<'tcx>;
}
Required Methods
sourcefn substitute(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>
) -> Vwhere
V: TypeFoldable<'tcx>,
fn substitute(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>
) -> Vwhere
V: TypeFoldable<'tcx>,
Instantiate the wrapped value, replacing each canonical value
with the value given in var_values
.
sourcefn substitute_projected<T>(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>,
projection_fn: impl FnOnce(&V) -> T
) -> Twhere
T: TypeFoldable<'tcx>,
fn substitute_projected<T>(
&self,
tcx: TyCtxt<'tcx>,
var_values: &CanonicalVarValues<'tcx>,
projection_fn: impl FnOnce(&V) -> T
) -> Twhere
T: TypeFoldable<'tcx>,
Allows one to apply a substitute to some subset of
self.value
. Invoke projection_fn
with self.value
to get
a value V that is expressed in terms of the same canonical
variables bound in self
(usually this extracts from subset
of self
). Apply the substitution var_values
to this value
V, replacing each of the canonical variables.