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

pub enum TyKind<'tcx> {
Show 27 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),
}
Expand description

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.

Tuple Fields of Int

0: IntTy
Uint(UintTy)

A primitive unsigned integer type. For example, u32.

Tuple Fields of Uint

0: UintTy
Float(FloatTy)

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

Tuple Fields of Float

0: FloatTy
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.

Tuple Fields of Adt

0: &'tcx AdtDef1: SubstsRef<'tcx>
Foreign(DefId)

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

Tuple Fields of Foreign

0: DefId
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].

Tuple Fields of Array

0: Ty<'tcx>1: &'tcx Const<'tcx>
Slice(Ty<'tcx>)

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

Tuple Fields of Slice

0: Ty<'tcx>
RawPtr(TypeAndMut<'tcx>)

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

Tuple Fields of RawPtr

0: TypeAndMut<'tcx>
Ref(Region<'tcx>, Ty<'tcx>, Mutability)

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

Tuple Fields of Ref

0: Region<'tcx>1: Ty<'tcx>2: Mutability
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}

Tuple Fields of FnDef

0: DefId1: SubstsRef<'tcx>
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;

Tuple Fields of FnPtr

0: PolyFnSig<'tcx>
Dynamic(&'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>, Region<'tcx>)

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

Tuple Fields of Dynamic

0: &'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>1: Region<'tcx>
Closure(DefIdSubstsRef<'tcx>)

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

Tuple Fields of Closure

0: DefId1: SubstsRef<'tcx>
Generator(DefIdSubstsRef<'tcx>, Movability)

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

Tuple Fields of Generator

0: DefId1: SubstsRef<'tcx>2: Movability
GeneratorWitness(Binder<'tcx, &'tcx List<Ty<'tcx>>>)

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

Tuple Fields of GeneratorWitness

0: Binder<'tcx, &'tcx List<Ty<'tcx>>>
Never

The never type !.

Tuple(SubstsRef<'tcx>)

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

Tuple Fields of Tuple

0: SubstsRef<'tcx>
Projection(ProjectionTy<'tcx>)

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

Tuple Fields of Projection

0: ProjectionTy<'tcx>
Opaque(DefIdSubstsRef<'tcx>)

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

Tuple Fields of Opaque

0: DefId1: SubstsRef<'tcx>
Param(ParamTy)

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

Tuple Fields of Param

0: ParamTy
Bound(DebruijnIndexBoundTy)

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

Tuple Fields of Bound

0: DebruijnIndex1: BoundTy
Placeholder(PlaceholderType)

A placeholder type - universally quantified higher-ranked type.

Tuple Fields of Placeholder

0: PlaceholderType
Infer(InferTy)

A type variable used during type checking.

Tuple Fields of Infer

0: InferTy
Error(DelaySpanBugEmitted)

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

Tuple Fields of Error

0: DelaySpanBugEmitted

Implementations

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

Trait Implementations

Immutably borrows from an owned value. Read more

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Feeds this value into the given Hasher. Read more

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

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

Compares and returns the maximum of two values. Read more

Compares and returns the minimum of two values. Read more

Restrict a value to a certain interval. Read more

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

This method tests for !=.

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

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

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

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

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

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

This method turns the parameters of a DepNodeConstructor into an opaque Fingerprint to be used in DepNode. Not all DepNodeParams support being turned into a Fingerprint (they don’t need to if the corresponding DepNode is anonymous). Read more

This method tries to recover the query key from the given 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. Read more

Performs the conversion.

Performs the conversion.

The resulting type after obtaining ownership.

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

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

recently added

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

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.

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: 32 bytes

Size for each variant: