Type Alias rustc_middle::ty::generic_args::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> {
    skel: ListSkeleton<(), GenericArg<'tcx>>,
    opaque: OpaqueListContents,
}

Fields§

§skel: ListSkeleton<(), GenericArg<'tcx>>§opaque: OpaqueListContents

Implementations§

source§

impl<'tcx> GenericArgs<'tcx>

source

pub fn into_type_list(&self, tcx: TyCtxt<'tcx>) -> &'tcx List<Ty<'tcx>>

Converts generic args to a type list.

§Panics

If any of the generic arguments are not types.

source

pub fn as_closure(&'tcx self) -> ClosureArgs<TyCtxt<'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.

source

pub fn as_coroutine_closure(&'tcx self) -> CoroutineClosureArgs<TyCtxt<'tcx>>

Interpret these generic args as the args of a coroutine-closure type. Coroutine-closure args have a particular structure controlled by the compiler that encodes information like the signature and closure kind; see ty::CoroutineClosureArgs struct for more comments.

source

pub fn as_coroutine(&'tcx self) -> CoroutineArgs<TyCtxt<'tcx>>

Interpret these generic args as the args of a coroutine type. Coroutine args have a particular structure controlled by the compiler that encodes information like the signature and coroutine kind; see ty::CoroutineArgs struct for more comments.

source

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.

source

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.

source

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.

source

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>,

source

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>,

source

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>,

source

pub fn extend_with_error( tcx: TyCtxt<'tcx>, def_id: DefId, original_args: &[GenericArg<'tcx>], ) -> GenericArgsRef<'tcx>

source

pub fn types(&'tcx self) -> impl DoubleEndedIterator<Item = Ty<'tcx>> + 'tcx

source

pub fn regions( &'tcx self, ) -> impl DoubleEndedIterator<Item = Region<'tcx>> + 'tcx

source

pub fn consts(&'tcx self) -> impl DoubleEndedIterator<Item = Const<'tcx>> + 'tcx

source

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.

source

pub fn type_at(&self, i: usize) -> Ty<'tcx>

source

pub fn region_at(&self, i: usize) -> Region<'tcx>

source

pub fn const_at(&self, i: usize) -> Const<'tcx>

source

pub fn type_for_def(&self, def: &GenericParamDef) -> GenericArg<'tcx>

source

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 of f 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 for f in the impl that are needed for it to match the trait.
source

pub fn truncate_to( &self, tcx: TyCtxt<'tcx>, generics: &Generics, ) -> GenericArgsRef<'tcx>

source

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)