pub struct GenericArgs<'tcx>(&'tcx GenericArgsUnsized<'tcx>);Expand description
List of generic arguments that are gonna be used to replace generic parameters.
Tuple Fields§
§0: &'tcx GenericArgsUnsized<'tcx>Implementations§
Source§impl<'tcx> GenericArgs<'tcx>
impl<'tcx> GenericArgs<'tcx>
pub fn empty() -> Self
Sourcepub fn as_ptr(&self) -> *const ()
👎Deprecated: do not call this
pub fn as_ptr(&self) -> *const ()
do not call this
Exposes the underlying pointer. Relying on this for equality won’t always be supported. Be careful.
pub fn iter(self) -> Copied<Iter<'tcx, GenericArg<'tcx>>> ⓘ
pub fn get(self, idx: usize) -> Option<GenericArg<'tcx>>
pub fn first(self) -> Option<GenericArg<'tcx>>
pub fn as_slice(&self) -> &[GenericArg<'tcx>]
pub fn is_empty(&self) -> bool
pub fn len(&self) -> usize
pub fn as_tcx_slice(&self) -> &'tcx [GenericArg<'tcx>]
pub fn from_args(args: &'tcx GenericArgsUnsized<'tcx>) -> Self
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(self) -> ClosureArgs<TyCtxt<'tcx>>
pub fn as_closure(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.
Sourcepub fn as_coroutine_closure(self) -> CoroutineClosureArgs<TyCtxt<'tcx>>
pub fn as_coroutine_closure(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.
Sourcepub fn as_coroutine(self) -> CoroutineArgs<TyCtxt<'tcx>>
pub fn as_coroutine(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.
Sourcepub fn as_inline_const(self) -> InlineConstArgs<'tcx>
pub fn as_inline_const(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>,
) -> GenericArgs<'tcx>
pub fn identity_for_item( tcx: TyCtxt<'tcx>, def_id: impl Into<DefId>, ) -> GenericArgs<'tcx>
Creates a GenericArgs that maps each generic parameter to itself.
Sourcepub fn for_item<F>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
mk_kind: F,
) -> GenericArgs<'tcx>
pub fn for_item<F>( tcx: TyCtxt<'tcx>, def_id: DefId, mk_kind: F, ) -> GenericArgs<'tcx>
Creates a 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, ) -> GenericArgs<'tcx>
pub fn fill_item<F>( args: &mut SmallVec<[GenericArg<'tcx>; 8]>, tcx: TyCtxt<'tcx>, defs: &Generics, mk_kind: &mut F, )
pub fn fill_single<F>( args: &mut SmallVec<[GenericArg<'tcx>; 8]>, defs: &Generics, mk_kind: &mut F, )
pub fn extend_with_error( tcx: TyCtxt<'tcx>, def_id: DefId, original_args: &[GenericArg<'tcx>], ) -> GenericArgs<'tcx>
pub fn types(&self) -> impl DoubleEndedIterator<Item = Ty<'tcx>>
pub fn regions(&self) -> impl DoubleEndedIterator<Item = Region<'tcx>>
pub fn consts(&self) -> impl DoubleEndedIterator<Item = Const<'tcx>>
pub fn terms(&self) -> impl DoubleEndedIterator<Item = Term<'tcx>>
Sourcepub fn non_erasable_generics(
&self,
) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>>
pub fn non_erasable_generics( &self, ) -> impl DoubleEndedIterator<Item = GenericArgKind<'tcx>>
Returns generic arguments that are not lifetimes.
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: GenericArgs<'tcx>,
) -> GenericArgs<'tcx>
pub fn rebase_onto( &self, tcx: TyCtxt<'tcx>, source_ancestor: DefId, target_args: GenericArgs<'tcx>, ) -> GenericArgs<'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
selfis[Self, S, T]: the identity args offin the trait. - If
source_ancestoris the def_id of the trait. - If
target_argsis[U], the args for the impl. - Then we will return
[U, T], the arg forfin the impl that are needed for it to match the trait.
Sourcepub fn truncate_to(
&self,
tcx: TyCtxt<'tcx>,
generics: &Generics,
) -> GenericArgs<'tcx>
pub fn truncate_to( &self, tcx: TyCtxt<'tcx>, generics: &Generics, ) -> GenericArgs<'tcx>
Truncates this list of generic args to have at most the number of args in generics.
You might be looking for TraitRef::from_assoc.
pub fn print_as_list(&self) -> String
Trait Implementations§
Source§impl<'tcx> AsRef<[GenericArg<'tcx>]> for GenericArgs<'tcx>
impl<'tcx> AsRef<[GenericArg<'tcx>]> for GenericArgs<'tcx>
Source§fn as_ref(&self) -> &[GenericArg<'tcx>]
fn as_ref(&self) -> &[GenericArg<'tcx>]
Source§impl<'tcx> Clone for GenericArgs<'tcx>
impl<'tcx> Clone for GenericArgs<'tcx>
impl<'tcx> Copy for GenericArgs<'tcx>
Source§impl<'tcx> Debug for GenericArgs<'tcx>
impl<'tcx> Debug for GenericArgs<'tcx>
Source§impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for GenericArgs<'tcx>
impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for GenericArgs<'tcx>
Source§impl<'tcx> Default for GenericArgs<'tcx>
impl<'tcx> Default for GenericArgs<'tcx>
Source§impl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for GenericArgs<'tcx>
impl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for GenericArgs<'tcx>
impl<'tcx> Eq for GenericArgs<'tcx>
Source§impl Erasable for GenericArgs<'_>
impl Erasable for GenericArgs<'_>
Source§impl<'tcx> GenericArgs<TyCtxt<'tcx>> for GenericArgs<'tcx>
impl<'tcx> GenericArgs<TyCtxt<'tcx>> for GenericArgs<'tcx>
fn rebase_onto( self, tcx: TyCtxt<'tcx>, source_ancestor: DefId, target_args: GenericArgs<'tcx>, ) -> GenericArgs<'tcx>
fn type_at(self, i: usize) -> Ty<'tcx>
fn region_at(self, i: usize) -> Region<'tcx>
fn const_at(self, i: usize) -> Const<'tcx>
fn identity_for_item(tcx: TyCtxt<'tcx>, def_id: DefId) -> GenericArgs<'tcx>
fn extend_with_error( tcx: TyCtxt<'tcx>, def_id: DefId, original_args: &[GenericArg<'tcx>], ) -> GenericArgs<'tcx>
fn split_closure_args<'a>(&'a self) -> ClosureArgsParts<'a, TyCtxt<'tcx>>
fn split_coroutine_closure_args<'a>( &'a self, ) -> CoroutineClosureArgsParts<'a, TyCtxt<'tcx>>
fn split_coroutine_args<'a>(&'a self) -> CoroutineArgsParts<'a, TyCtxt<'tcx>>
fn as_closure(self) -> ClosureArgs<I>
fn as_coroutine_closure(self) -> CoroutineClosureArgs<I>
fn as_coroutine(self) -> CoroutineArgs<I>
Source§impl<'tcx> Hash for GenericArgs<'tcx>
impl<'tcx> Hash for GenericArgs<'tcx>
Source§impl<'tcx> Index<usize> for GenericArgs<'tcx>
impl<'tcx> Index<usize> for GenericArgs<'tcx>
Source§impl<'tcx> IntoIterator for GenericArgs<'tcx>
impl<'tcx> IntoIterator for GenericArgs<'tcx>
Source§impl<'tcx, '__lifted> Lift<TyCtxt<'__lifted>> for GenericArgs<'tcx>
impl<'tcx, '__lifted> Lift<TyCtxt<'__lifted>> for GenericArgs<'tcx>
type Lifted = GenericArgs<'__lifted>
fn lift_to_interner(self, __tcx: TyCtxt<'__lifted>) -> GenericArgs<'__lifted>
Source§impl<'tcx> PartialEq for GenericArgs<'tcx>
impl<'tcx> PartialEq for GenericArgs<'tcx>
Source§impl<'tcx> QueryKey for GenericArgs<'tcx>
impl<'tcx> QueryKey for GenericArgs<'tcx>
Source§fn default_span(&self, _: TyCtxt<'_>) -> Span
fn default_span(&self, _: TyCtxt<'_>) -> Span
self, what span should we use?Source§type Cache<V> = DefaultCache<Self, V>
type Cache<V> = DefaultCache<Self, V>
type LocalQueryKey = !
Source§fn key_as_def_id(&self) -> Option<DefId>
fn key_as_def_id(&self) -> Option<DefId>
Source§fn as_local_key(&self) -> Option<Self::LocalQueryKey>
fn as_local_key(&self) -> Option<Self::LocalQueryKey>
Source§impl<'tcx> Relate<TyCtxt<'tcx>> for GenericArgs<'tcx>
impl<'tcx> Relate<TyCtxt<'tcx>> for GenericArgs<'tcx>
fn relate<R: TypeRelation<TyCtxt<'tcx>>>( relation: &mut R, a: GenericArgs<'tcx>, b: GenericArgs<'tcx>, ) -> RelateResult<'tcx, GenericArgs<'tcx>>
Source§impl<'tcx> SliceLike for GenericArgs<'tcx>
impl<'tcx> SliceLike for GenericArgs<'tcx>
type Item = GenericArg<'tcx>
type IntoIter = Copied<Iter<'tcx, GenericArg<'tcx>>>
fn iter(self) -> Self::IntoIter
fn as_slice(&self) -> &[Self::Item]
fn get(self, idx: usize) -> Option<Self::Item>
fn len(self) -> usize
fn is_empty(self) -> bool
fn contains(self, t: &Self::Item) -> bool
fn to_vec(self) -> Vec<Self::Item>
fn last(self) -> Option<Self::Item>
fn split_last(&self) -> Option<(&Self::Item, &[Self::Item])>
Source§impl<'tcx> StableHash for GenericArgs<'tcx>
impl<'tcx> StableHash for GenericArgs<'tcx>
fn stable_hash<__Hcx: StableHashCtxt>( &self, __hcx: &mut __Hcx, __hasher: &mut StableHasher, )
impl<'tcx> StructuralPartialEq for GenericArgs<'tcx>
Source§impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArgs<'tcx>
impl<'tcx> TypeFoldable<TyCtxt<'tcx>> for GenericArgs<'tcx>
Source§fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>(
self,
folder: &mut F,
) -> Result<Self, F::Error>
fn try_fold_with<F: FallibleTypeFolder<TyCtxt<'tcx>>>( self, folder: &mut F, ) -> Result<Self, F::Error>
Source§impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArgs<'tcx>
impl<'tcx> TypeVisitable<TyCtxt<'tcx>> for GenericArgs<'tcx>
Source§fn visit_with<__V: TypeVisitor<TyCtxt<'tcx>>>(
&self,
__visitor: &mut __V,
) -> __V::Result
fn visit_with<__V: TypeVisitor<TyCtxt<'tcx>>>( &self, __visitor: &mut __V, ) -> __V::Result
Auto Trait Implementations§
impl<'tcx> !RefUnwindSafe for GenericArgs<'tcx>
impl<'tcx> !UnwindSafe for GenericArgs<'tcx>
impl<'tcx> DynSend for GenericArgs<'tcx>
impl<'tcx> DynSync for GenericArgs<'tcx>
impl<'tcx> Freeze for GenericArgs<'tcx>
impl<'tcx> Send for GenericArgs<'tcx>
impl<'tcx> Sync for GenericArgs<'tcx>
impl<'tcx> Unpin for GenericArgs<'tcx>
impl<'tcx> UnsafeUnpin for GenericArgs<'tcx>
Blanket Implementations§
Source§impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for Twhere
T: Copy,
fn allocate_on(self, arena: &'tcx Arena<'tcx>) -> &'tcx mut T
fn allocate_from_iter( arena: &'tcx Arena<'tcx>, iter: impl IntoIterator<Item = T>, ) -> &'tcx mut [T]
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<'tcx, T> DepNodeKey<'tcx> for Twhere
T: StableHash + Debug,
impl<'tcx, T> DepNodeKey<'tcx> for Twhere
T: StableHash + Debug,
default fn key_fingerprint_style() -> KeyFingerprintStyle
Source§default fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
default fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint
Fingerprint to be used
in DepNode.Source§default fn try_recover_key(_: TyCtxt<'tcx>, _: &DepNode) -> Option<T>
default fn try_recover_key(_: TyCtxt<'tcx>, _: &DepNode) -> Option<T>
DepNode,
something which is needed when forcing DepNodes during red-green
evaluation. The query system will only call this method if
fingerprint_style() is not FingerprintStyle::Opaque.
It is always valid to return None here, in which case incremental
compilation will treat the query as having changed instead of forcing it.Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.impl<T> ErasedDestructor for Twhere
T: 'static,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
fn instrument(self, span: Span) -> Instrumented<Self> ⓘ
Source§fn in_current_span(self) -> Instrumented<Self> ⓘ
fn in_current_span(self) -> Instrumented<Self> ⓘ
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<K> IntoQueryKey<K> for K
impl<K> IntoQueryKey<K> for K
Source§fn into_query_key(self) -> K
fn into_query_key(self) -> K
Self to K.
This should always be a very cheap conversion, e.g. LocalDefId::to_def_id.Source§impl<'tcx, T> IsSuggestable<'tcx> for T
impl<'tcx, T> IsSuggestable<'tcx> for T
Source§impl<T> MaybeResult<T> for T
impl<T> MaybeResult<T> for T
Source§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T> TypeVisitableExt<I> for Twhere
I: Interner,
T: TypeVisitable<I>,
impl<I, T> TypeVisitableExt<I> for Twhere
I: Interner,
T: TypeVisitable<I>,
fn has_type_flags(&self, flags: TypeFlags) -> bool
Source§fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
fn has_vars_bound_at_or_above(&self, binder: DebruijnIndex) -> bool
true if self has any late-bound regions that are either
bound by binder or bound by some binder outside of binder.
If binder is ty::INNERMOST, this indicates whether
there are any late-bound regions that appear free.fn error_reported(&self) -> Result<(), <I as Interner>::ErrorGuaranteed>
fn non_region_error_reported( &self, ) -> Result<(), <I as Interner>::ErrorGuaranteed>
Source§fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool
fn has_vars_bound_above(&self, binder: DebruijnIndex) -> bool
true if this type has any regions that escape binder (and
hence are not bound by it).Source§fn has_escaping_bound_vars(&self) -> bool
fn has_escaping_bound_vars(&self) -> bool
true if this type has regions that are not a part of the
type. For example, given a for<'a> fn(&'a i32) this function returns
false, while given a fn(&'a i32) it returns true. The latter can
occur when traversing through the former. Read morefn has_aliases(&self) -> bool
fn has_opaque_types(&self) -> bool
fn has_coroutines(&self) -> bool
fn references_error(&self) -> bool
fn has_non_region_param(&self) -> bool
fn has_regions(&self) -> bool
fn has_infer_regions(&self) -> bool
fn has_infer_types(&self) -> bool
fn has_non_region_infer(&self) -> bool
fn has_infer(&self) -> bool
fn has_placeholders(&self) -> bool
fn has_non_region_placeholders(&self) -> bool
fn has_param(&self) -> bool
Source§fn has_free_regions(&self) -> bool
fn has_free_regions(&self) -> bool
fn has_erased_regions(&self) -> bool
Source§fn has_erasable_regions(&self) -> bool
fn has_erasable_regions(&self) -> bool
Source§fn is_global(&self) -> bool
fn is_global(&self) -> bool
Source§fn has_bound_regions(&self) -> bool
fn has_bound_regions(&self) -> bool
Source§fn has_non_region_bound_vars(&self) -> bool
fn has_non_region_bound_vars(&self) -> bool
Source§fn has_bound_vars(&self) -> bool
fn has_bound_vars(&self) -> bool
Source§fn still_further_specializable(&self) -> bool
fn still_further_specializable(&self) -> bool
impl
specialization.Source§fn has_non_region_error(&self) -> bool
fn has_non_region_error(&self) -> bool
Source§fn has_rigid_aliases(&self) -> bool
fn has_rigid_aliases(&self) -> bool
IsRigid::Yes. Used for skipping normalization.Source§fn has_non_rigid_aliases(&self) -> bool
fn has_non_rigid_aliases(&self) -> bool
IsRigid::No.Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> ⓘ
Source§fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
fn with_current_subscriber(self) -> WithDispatch<Self> ⓘ
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: 8 bytes