Struct rustc_middle::ty::subst::GenericArg[][src]

pub struct GenericArg<'tcx> {
    ptr: NonZeroUsize,
    marker: PhantomData<(Ty<'tcx>, Region<'tcx>, &'tcx Const<'tcx>)>,

An entity in the Rust type system, which can be one of several kinds (types, lifetimes, and consts). To reduce memory usage, a GenericArg is a interned pointer, with the lowest 2 bits being reserved for a tag to indicate the type (Ty, Region, or Const) it points to.


ptr: NonZeroUsizemarker: PhantomData<(Ty<'tcx>, Region<'tcx>, &'tcx Const<'tcx>)>


impl<'tcx> GenericArg<'tcx>[src]

pub fn unpack(self) -> GenericArgKind<'tcx>[src]

pub fn expect_ty(self) -> Ty<'tcx>[src]

Unpack the GenericArg as a type when it is known certainly to be a type. This is true in cases where Substs is used in places where the kinds are known to be limited (e.g. in tuples, where the only parameters are type parameters).

pub fn expect_const(self) -> &'tcx Const<'tcx>[src]

Unpack the GenericArg as a const when it is known certainly to be a const.

impl<'tcx> GenericArg<'tcx>[src]

pub fn walk(self) -> TypeWalker<'tcx>

Notable traits for TypeWalker<'tcx>

impl<'tcx> Iterator for TypeWalker<'tcx> type Item = GenericArg<'tcx>;

Iterator that walks self and any types reachable from self, in depth-first order. Note that just walks the types that appear in self, it does not descend into the fields of structs or variants. For example:

isize => { isize }
Foo<Bar<isize>> => { Foo<Bar<isize>>, Bar<isize>, isize }
[isize] => { [isize], isize }

pub fn walk_shallow(
    visited: &mut SsoHashSet<GenericArg<'tcx>>
) -> impl Iterator<Item = GenericArg<'tcx>>

Iterator that walks the immediate children of self. Hence Foo<Bar<i32>, u32> yields the sequence [Bar<i32>, u32] (but not i32, like walk).

Iterator only walks items once. It accepts visited set, updates it with all visited types and skips any types that are already there.

Trait Implementations

impl<'tcx> Clone for GenericArg<'tcx>[src]

impl<'tcx> Copy for GenericArg<'tcx>[src]

impl<'tcx> Debug for GenericArg<'tcx>[src]

impl<'tcx, D: TyDecoder<'tcx>> Decodable<D> for GenericArg<'tcx>[src]

impl<'tcx> Display for GenericArg<'tcx>[src]

impl<'tcx, E: TyEncoder<'tcx>> Encodable<E> for GenericArg<'tcx>[src]

impl<'tcx> Eq for GenericArg<'tcx>[src]

impl<'tcx> From<&'tcx Const<'tcx>> for GenericArg<'tcx>[src]

impl<'tcx> From<&'tcx RegionKind> for GenericArg<'tcx>[src]

impl<'tcx> From<&'tcx TyS<'tcx>> for GenericArg<'tcx>[src]

impl<'tcx> Hash for GenericArg<'tcx>[src]

impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for GenericArg<'tcx>[src]

impl<'a, 'tcx> Lift<'tcx> for GenericArg<'a>[src]

type Lifted = GenericArg<'tcx>

impl<'tcx> Ord for GenericArg<'tcx>[src]

impl<'tcx> PartialEq<GenericArg<'tcx>> for GenericArg<'tcx>[src]

impl<'tcx> PartialOrd<GenericArg<'tcx>> for GenericArg<'tcx>[src]

impl<'tcx, P: PrettyPrinter<'tcx>> Print<'tcx, P> for GenericArg<'tcx>[src]

type Output = P

type Error = Error

impl<'tcx> Relate<'tcx> for GenericArg<'tcx>[src]

impl<'tcx> StructuralEq for GenericArg<'tcx>[src]

impl<'tcx> StructuralPartialEq for GenericArg<'tcx>[src]

impl<'tcx> TypeFoldable<'tcx> for GenericArg<'tcx>[src]

Auto Trait Implementations

impl<'tcx> !RefUnwindSafe for GenericArg<'tcx>

impl<'tcx> !Send for GenericArg<'tcx>

impl<'tcx> !Sync for GenericArg<'tcx>

impl<'tcx> Unpin for GenericArg<'tcx>

impl<'tcx> !UnwindSafe for GenericArg<'tcx>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized

impl<'tcx, T> ArenaAllocatable<'tcx, ()> for T where
    T: Copy

impl<T> Borrow<T> for T where
    T: ?Sized

impl<T> BorrowMut<T> for T where
    T: ?Sized

impl<'a, T> Captures<'a> for T where
    T: ?Sized

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 

impl<T> MaybeResult<T> for T[src]

type Error = !

impl<'tcx, T> Subst<'tcx> for T where
    T: TypeFoldable<'tcx>, 

impl<T> ToOwned for T where
    T: Clone

type Owned = T

The resulting type after obtaining ownership.

impl<T> ToString for T where
    T: Display + ?Sized

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.

impl<T> WithConstness for T[src]