Type Definition rustc_middle::ty::subst::InternalSubsts
source · pub type InternalSubsts<'tcx> = List<GenericArg<'tcx>>;
Expand description
List of generic arguments that are gonna be used to substitute generic parameters.
Implementations§
source§impl<'tcx> InternalSubsts<'tcx>
impl<'tcx> InternalSubsts<'tcx>
sourcepub fn try_as_type_list(&'tcx self) -> Option<&'tcx List<Ty<'tcx>>>
pub fn try_as_type_list(&'tcx self) -> Option<&'tcx List<Ty<'tcx>>>
Checks whether all elements of this list are types, if so, transmute.
sourcepub fn as_closure(&'tcx self) -> ClosureSubsts<'tcx>
pub fn as_closure(&'tcx self) -> ClosureSubsts<'tcx>
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.
sourcepub fn as_generator(&'tcx self) -> GeneratorSubsts<'tcx>
pub fn as_generator(&'tcx self) -> GeneratorSubsts<'tcx>
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.
sourcepub fn as_inline_const(&'tcx self) -> InlineConstSubsts<'tcx>
pub fn as_inline_const(&'tcx self) -> InlineConstSubsts<'tcx>
Interpret these substitutions as the substitutions of an inline const.
Inline const substitutions have a particular structure controlled by the
compiler that encodes information like the inferred type;
see ty::InlineConstSubsts
struct for more comments.
sourcepub fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx>
pub fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> SubstsRef<'tcx>
Creates an InternalSubsts
that maps each generic parameter to itself.
sourcepub 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 extend_with_error(
tcx: TyCtxt<'tcx>,
def_id: DefId,
original_substs: &[GenericArg<'tcx>]
) -> SubstsRef<'tcx>
pub fn types(&'tcx self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> + 'tcx
pub fn regions(
&'tcx self
) -> impl DoubleEndedIterator<Item = Region<'tcx>> + 'tcx
pub fn consts(&'tcx self) -> impl DoubleEndedIterator<Item = Const<'tcx>> + 'tcx
pub fn non_erasable_generics(
&'tcx self
) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> + 'tcx
pub fn type_at(&self, i: usize) -> Ty<'tcx>
pub fn region_at(&self, i: usize) -> Region<'tcx>
pub fn const_at(&self, i: usize) -> Const<'tcx>
pub fn type_for_def(&self, def: &GenericParamDef) -> GenericArg<'tcx>
sourcepub fn rebase_onto(
&self,
tcx: TyCtxt<'tcx>,
source_ancestor: DefId,
target_substs: SubstsRef<'tcx>
) -> SubstsRef<'tcx>
pub fn rebase_onto(
&self,
tcx: TyCtxt<'tcx>,
source_ancestor: DefId,
target_substs: SubstsRef<'tcx>
) -> SubstsRef<'tcx>
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
self
is[Self, S, T]
: the identity substs off
in the trait. - If
source_ancestor
is the def_id of the trait. - If
target_substs
is[U]
, the substs for the impl. - Then we will return
[U, T]
, the subst forf
in the impl that are needed for it to match the trait.
pub fn truncate_to(
&self,
tcx: TyCtxt<'tcx>,
generics: &Generics
) -> SubstsRef<'tcx>
Layout§
Note: Most layout information is completely unstable and may even differ between compilations. The only exception is types with certain repr(...)
attributes. Please see the Rust Reference’s “Type Layout” chapter for details on type layout guarantees.
Size: (unsized)