Type Alias rustc_middle::ty::GenericArgs
source · pub type GenericArgs<'tcx> = List<GenericArg<'tcx>>;
Expand description
List of generic arguments that are gonna be used to replace generic parameters.
Aliased Type§
struct GenericArgs<'tcx> {
len: usize,
data: [GenericArg<'tcx>; 0],
opaque: OpaqueListContents,
}
Fields§
§len: usize
§data: [GenericArg<'tcx>; 0]
Although this claims to be a zero-length array, in practice len
elements are actually present.
opaque: OpaqueListContents
Implementations§
source§impl<'tcx> GenericArgs<'tcx>
impl<'tcx> GenericArgs<'tcx>
sourcepub fn into_type_list(&self, tcx: TyCtxt<'tcx>) -> &'tcx List<Ty<'tcx>>
pub fn into_type_list(&self, tcx: TyCtxt<'tcx>) -> &'tcx List<Ty<'tcx>>
sourcepub fn as_closure(&'tcx self) -> ClosureArgs<'tcx>
pub fn as_closure(&'tcx self) -> ClosureArgs<'tcx>
Interpret these generic args as the args of a closure type.
Closure args have a particular structure controlled by the
compiler that encodes information like the signature and closure kind;
see ty::ClosureArgs
struct for more comments.
sourcepub fn as_generator(&'tcx self) -> GeneratorArgs<'tcx>
pub fn as_generator(&'tcx self) -> GeneratorArgs<'tcx>
Interpret these generic args as the args of a generator type.
Generator args have a particular structure controlled by the
compiler that encodes information like the signature and generator kind;
see ty::GeneratorArgs
struct for more comments.
sourcepub fn as_inline_const(&'tcx self) -> InlineConstArgs<'tcx>
pub fn as_inline_const(&'tcx self) -> InlineConstArgs<'tcx>
Interpret these generic args as the args of an inline const.
Inline const args have a particular structure controlled by the
compiler that encodes information like the inferred type;
see ty::InlineConstArgs
struct for more comments.
sourcepub fn identity_for_item(
tcx: TyCtxt<'tcx>,
def_id: impl Into<DefId>
) -> GenericArgsRef<'tcx>
pub fn identity_for_item( tcx: TyCtxt<'tcx>, def_id: impl Into<DefId> ) -> GenericArgsRef<'tcx>
Creates an GenericArgs
that maps each generic parameter to itself.
sourcepub fn for_item<F>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
mk_kind: F
) -> GenericArgsRef<'tcx>where
F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn for_item<F>( tcx: TyCtxt<'tcx>, def_id: DefId, mk_kind: F ) -> GenericArgsRef<'tcx>where F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
Creates an GenericArgs
for generic parameter definitions,
by calling closures to obtain each kind.
The closures get to observe the GenericArgs
as they’re
being built, which can be used to correctly
replace defaults of generic parameters.
pub fn extend_to<F>( &self, tcx: TyCtxt<'tcx>, def_id: DefId, mk_kind: F ) -> GenericArgsRef<'tcx>where F: FnMut(&GenericParamDef, &[GenericArg<'tcx>]) -> GenericArg<'tcx>,
pub fn fill_item<F>( args: &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>( args: &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_args: &[GenericArg<'tcx>] ) -> GenericArgsRef<'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
sourcepub fn non_erasable_generics(
&'tcx self,
tcx: TyCtxt<'tcx>,
def_id: DefId
) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> + 'tcx
pub fn non_erasable_generics( &'tcx self, tcx: TyCtxt<'tcx>, def_id: DefId ) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>> + 'tcx
Returns generic arguments that are not lifetimes or host effect params.
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_args: GenericArgsRef<'tcx>
) -> GenericArgsRef<'tcx>
pub fn rebase_onto( &self, tcx: TyCtxt<'tcx>, source_ancestor: DefId, target_args: GenericArgsRef<'tcx> ) -> GenericArgsRef<'tcx>
Transform from generic args for a child of source_ancestor
(e.g., a trait or impl) to args for the same child
in a different item, with target_args
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 args off
in the trait. - If
source_ancestor
is the def_id of the trait. - If
target_args
is[U]
, the args for the impl. - Then we will return
[U, T]
, the arg forf
in the impl that are needed for it to match the trait.
pub fn truncate_to( &self, tcx: TyCtxt<'tcx>, generics: &Generics ) -> GenericArgsRef<'tcx>
pub fn host_effect_param(&'tcx self) -> Option<Const<'tcx>>
pub fn print_as_list(&self) -> String
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)