Type Definition rustc_middle::ty::subst::InternalSubsts [−][src]
pub type InternalSubsts<'tcx> = List<GenericArg<'tcx>>;Expand description
A substitution mapping generic parameters to new values.
Implementations
Interpret these substitutions as the substitutions of a closure type.
Closure substitutions have a particular structure controlled by the
compiler that encodes information like the signature and closure kind;
see ty::ClosureSubsts struct for more comments.
Interpret these substitutions as the substitutions of a generator type.
Generator substitutions have a particular structure controlled by the
compiler that encodes information like the signature and generator kind;
see ty::GeneratorSubsts struct for more comments.
Creates an InternalSubsts that maps each generic parameter to itself.
pub fn for_item<F>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
mk_kind: F
) -> SubstsRef<'tcx> where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn for_item<F>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
mk_kind: F
) -> SubstsRef<'tcx> where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
Creates an InternalSubsts for generic parameter definitions,
by calling closures to obtain each kind.
The closures get to observe the InternalSubsts as they’re
being built, which can be used to correctly
substitute defaults of generic parameters.
pub fn extend_to<F>(
&self,
tcx: TyCtxt<'tcx>,
def_id: DefId,
mk_kind: F
) -> SubstsRef<'tcx> where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn fill_item<F>(
substs: &mut SmallVec<[GenericArg<'tcx>; 8]>,
tcx: TyCtxt<'tcx>,
defs: &Generics,
mk_kind: &mut F
) where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn fill_single<F>(
substs: &mut SmallVec<[GenericArg<'tcx>; 8]>,
defs: &Generics,
mk_kind: &mut F
) where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn non_erasable_generics(
&'a self
) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> + 'a
Transform from substitutions for a child of source_ancestor
(e.g., a trait or impl) to substitutions for the same child
in a different item, with target_substs as the base for
the target impl/trait, with the source child-specific
parameters (e.g., method parameters) on top of that base.
For example given:
trait X<S> { fn f<T>(); }
impl<U> X<U> for U { fn f<V>() {} }- If
selfis[Self, S, T]: the identity substs offin the trait. - If
source_ancestoris the def_id of the trait. - If
target_substsis[U], the substs for the impl. - Then we will return
[U, T], the subst forfin the impl that are needed for it to match the trait.