Enum rustc_middle::ty::sty::TyKind[][src]

pub enum TyKind<'tcx> {
Show variants Bool, Char, Int(IntTy), Uint(UintTy), Float(FloatTy), Adt(&'tcx AdtDefSubstsRef<'tcx>), Foreign(DefId), Str, Array(Ty<'tcx>, &'tcx Const<'tcx>), Slice(Ty<'tcx>), RawPtr(TypeAndMut<'tcx>), Ref(Region<'tcx>, Ty<'tcx>, Mutability), FnDef(DefIdSubstsRef<'tcx>), FnPtr(PolyFnSig<'tcx>), Dynamic(&'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>, Region<'tcx>), Closure(DefIdSubstsRef<'tcx>), Generator(DefIdSubstsRef<'tcx>, Movability), GeneratorWitness(Binder<'tcx, &'tcx List<Ty<'tcx>>>), Never, Tuple(SubstsRef<'tcx>), Projection(ProjectionTy<'tcx>), Opaque(DefIdSubstsRef<'tcx>), Param(ParamTy), Bound(DebruijnIndexBoundTy), Placeholder(PlaceholderType), Infer(InferTy), Error(DelaySpanBugEmitted),
}

Defines the kinds of types.

N.B., if you change this, you’ll probably want to change the corresponding AST structure in rustc_ast/src/ast.rs as well.

Variants

Bool

The primitive boolean type. Written as bool.

Char

The primitive character type; holds a Unicode scalar value (a non-surrogate code point). Written as char.

Int(IntTy)

A primitive signed integer type. For example, i32.

Uint(UintTy)

A primitive unsigned integer type. For example, u32.

Float(FloatTy)

A primitive floating-point type. For example, f64.

Adt(&'tcx AdtDefSubstsRef<'tcx>)

Algebraic data types (ADT). For example: structures, enumerations and unions.

InternalSubsts here, possibly against intuition, may contain Params. That is, even after substitution it is possible that there are type variables. This happens when the Adt corresponds to an ADT definition and not a concrete use of it.

Foreign(DefId)

An unsized FFI type that is opaque to Rust. Written as extern type T.

Str

The pointee of a string slice. Written as str.

Array(Ty<'tcx>, &'tcx Const<'tcx>)

An array with the given length. Written as [T; n].

Slice(Ty<'tcx>)

The pointee of an array slice. Written as [T].

RawPtr(TypeAndMut<'tcx>)

A raw pointer. Written as *mut T or *const T

Ref(Region<'tcx>, Ty<'tcx>, Mutability)

A reference; a pointer with an associated lifetime. Written as &'a mut T or &'a T.

FnDef(DefIdSubstsRef<'tcx>)

The anonymous type of a function declaration/definition. Each function has a unique type, which is output (for a function named foo returning an i32) as fn() -> i32 {foo}.

For example the type of bar here:

fn foo() -> i32 { 1 }
let bar = foo; // bar: fn() -> i32 {foo}
FnPtr(PolyFnSig<'tcx>)

A pointer to a function. Written as fn() -> i32.

For example the type of bar here:

fn foo() -> i32 { 1 }
let bar: fn() -> i32 = foo;
Dynamic(&'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>, Region<'tcx>)

A trait object. Written as dyn for<'b> Trait<'b, Assoc = u32> + Send + 'a.

Closure(DefIdSubstsRef<'tcx>)

The anonymous type of a closure. Used to represent the type of |a| a.

Generator(DefIdSubstsRef<'tcx>, Movability)

The anonymous type of a generator. Used to represent the type of |a| yield a.

GeneratorWitness(Binder<'tcx, &'tcx List<Ty<'tcx>>>)

A type representing the types stored inside a generator. This should only appear in GeneratorInteriors.

Never

The never type !.

Tuple(SubstsRef<'tcx>)

A tuple type. For example, (i32, bool). Use TyS::tuple_fields to iterate over the field types.

Projection(ProjectionTy<'tcx>)

The projection of an associated type. For example, <T as Trait<..>>::N.

Opaque(DefIdSubstsRef<'tcx>)

Opaque (impl Trait) type found in a return type. The DefId comes either from

Param(ParamTy)

A type parameter; for example, T in fn f<T>(x: T) {}.

Bound(DebruijnIndexBoundTy)

Bound type variable, used only when preparing a trait query.

Placeholder(PlaceholderType)

A placeholder type - universally quantified higher-ranked type.

Infer(InferTy)

A type variable used during type checking.

Error(DelaySpanBugEmitted)

A placeholder for a type which could not be computed; this is propagated to avoid useless error messages.

Implementations

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

pub fn is_primitive(&self) -> bool[src]

pub fn article(&self) -> &'static str[src]

Get the article (“a” or “an”) to use with this type.

Trait Implementations

impl<'tcx> Borrow<TyKind<'tcx>> for Interned<'tcx, TyS<'tcx>>[src]

fn borrow<'a>(&'a self) -> &'a TyKind<'tcx>[src]

Immutably borrows from an owned value. Read more

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

fn clone(&self) -> TyKind<'tcx>[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

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

fn fmt(&self, f: &mut Formatter<'_>) -> Result[src]

Formats the value using the given formatter. Read more

impl<'tcx, __D: TyDecoder<'tcx>> Decodable<__D> for TyKind<'tcx>[src]

fn decode(__decoder: &mut __D) -> Result<Self, <__D as Decoder>::Error>[src]

impl<'tcx, __E: TyEncoder<'tcx>> Encodable<__E> for TyKind<'tcx>[src]

fn encode(&self, __encoder: &mut __E) -> Result<(), <__E as Encoder>::Error>[src]

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

fn hash<__H: Hasher>(&self, state: &mut __H)[src]

Feeds this value into the given Hasher. Read more

fn hash_slice<H>(data: &[Self], state: &mut H) where
    H: Hasher
1.3.0[src]

Feeds a slice of this type into the given Hasher. Read more

impl<'tcx, '__ctx> HashStable<StableHashingContext<'__ctx>> for TyKind<'tcx>[src]

fn hash_stable(
    &self,
    __hcx: &mut StableHashingContext<'__ctx>,
    __hasher: &mut StableHasher
)
[src]

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

fn cmp(&self, other: &TyKind<'tcx>) -> Ordering[src]

This method returns an Ordering between self and other. Read more

#[must_use]
fn max(self, other: Self) -> Self
1.21.0[src]

Compares and returns the maximum of two values. Read more

#[must_use]
fn min(self, other: Self) -> Self
1.21.0[src]

Compares and returns the minimum of two values. Read more

#[must_use]
fn clamp(self, min: Self, max: Self) -> Self
1.50.0[src]

Restrict a value to a certain interval. Read more

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

fn eq(&self, other: &TyKind<'tcx>) -> bool[src]

This method tests for self and other values to be equal, and is used by ==. Read more

fn ne(&self, other: &TyKind<'tcx>) -> bool[src]

This method tests for !=.

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

fn partial_cmp(&self, other: &TyKind<'tcx>) -> Option<Ordering>[src]

This method returns an ordering between self and other values if one exists. Read more

#[must_use]
fn lt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than (for self and other) and is used by the < operator. Read more

#[must_use]
fn le(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests less than or equal to (for self and other) and is used by the <= operator. Read more

#[must_use]
fn gt(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than (for self and other) and is used by the > operator. Read more

#[must_use]
fn ge(&self, other: &Rhs) -> bool
1.0.0[src]

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more

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

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

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

Auto Trait Implementations

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

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

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

impl<'tcx> Unpin for TyKind<'tcx>

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

Blanket Implementations

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

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

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

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

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

type Error = !

pub fn from(Result<T, <T as MaybeResult<T>>::Error>) -> T[src]

pub fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>[src]

impl<T> ToOwned for T where
    T: Clone
[src]

type Owned = T

The resulting type after obtaining ownership.

pub fn to_owned(&self) -> T[src]

Creates owned data from borrowed data, usually by cloning. Read more

pub fn clone_into(&self, target: &mut T)[src]

🔬 This is a nightly-only experimental API. (toowned_clone_into)

recently added

Uses borrowed data to replace owned data, usually by cloning. Read more

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

pub fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>[src]

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

pub fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>[src]

Performs the conversion.

impl<T> WithConstness for T[src]

fn with_constness(self, constness: Constness) -> ConstnessAnd<Self>[src]

fn with_const(self) -> ConstnessAnd<Self>[src]

fn without_const(self) -> ConstnessAnd<Self>[src]

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