Enum rustc_monomorphize::ty::TyKind[−][src]

pub enum TyKind<'tcx> {
Show 27 variants Bool, Char, Int(IntTy), Uint(UintTy), Float(FloatTy), Adt(&'tcx AdtDef, &'tcx List<GenericArg<'tcx>>), Foreign(DefId), Str, Array(&'tcx TyS<'tcx>, &'tcx Const<'tcx>), Slice(&'tcx TyS<'tcx>), RawPtr(TypeAndMut<'tcx>), Ref(&'tcx RegionKind, &'tcx TyS<'tcx>, Mutability), FnDef(DefId, &'tcx List<GenericArg<'tcx>>), FnPtr(Binder<'tcx, FnSig<'tcx>>), Dynamic(&'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>, &'tcx RegionKind), Closure(DefId, &'tcx List<GenericArg<'tcx>>), Generator(DefId, &'tcx List<GenericArg<'tcx>>, Movability), GeneratorWitness(Binder<'tcx, &'tcx List<&'tcx TyS<'tcx>>>), Never, Tuple(&'tcx List<GenericArg<'tcx>>), Projection(ProjectionTy<'tcx>), Opaque(DefId, &'tcx List<GenericArg<'tcx>>), Param(ParamTy), Bound(DebruijnIndex, BoundTy), Placeholder(Placeholder<BoundVar>), 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)

Tuple Fields

0: IntTy

A primitive signed integer type. For example, i32.

Uint(UintTy)

Tuple Fields

0: UintTy

A primitive unsigned integer type. For example, u32.

Float(FloatTy)

Tuple Fields

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

Adt(&'tcx AdtDef, &'tcx List<GenericArg<'tcx>>)

Tuple Fields

0: &'tcx AdtDef
1: &'tcx List<GenericArg<'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)

Tuple Fields

0: 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(&'tcx TyS<'tcx>, &'tcx Const<'tcx>)

Tuple Fields

0: &'tcx TyS<'tcx>
1: &'tcx Const<'tcx>

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

Slice(&'tcx TyS<'tcx>)

Tuple Fields

0: &'tcx TyS<'tcx>

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

RawPtr(TypeAndMut<'tcx>)

Tuple Fields

0: TypeAndMut<'tcx>

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

Ref(&'tcx RegionKind, &'tcx TyS<'tcx>, Mutability)

Tuple Fields

0: &'tcx RegionKind
1: &'tcx TyS<'tcx>

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

FnDef(DefId, &'tcx List<GenericArg<'tcx>>)

Tuple Fields

0: DefId
1: &'tcx List<GenericArg<'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(Binder<'tcx, FnSig<'tcx>>)

Tuple Fields

0: Binder<'tcx, FnSig<'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>>>, &'tcx RegionKind)

Tuple Fields

0: &'tcx List<Binder<'tcx, ExistentialPredicate<'tcx>>>
1: &'tcx RegionKind

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

Closure(DefId, &'tcx List<GenericArg<'tcx>>)

Tuple Fields

0: DefId
1: &'tcx List<GenericArg<'tcx>>

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

Generator(DefId, &'tcx List<GenericArg<'tcx>>, Movability)

Tuple Fields

0: DefId
1: &'tcx List<GenericArg<'tcx>>

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

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

Tuple Fields

0: Binder<'tcx, &'tcx List<&'tcx TyS<'tcx>>>

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

Never

The never type !.

Tuple(&'tcx List<GenericArg<'tcx>>)

Tuple Fields

0: &'tcx List<GenericArg<'tcx>>

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

Projection(ProjectionTy<'tcx>)

Tuple Fields

0: ProjectionTy<'tcx>

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

Opaque(DefId, &'tcx List<GenericArg<'tcx>>)

Tuple Fields

0: DefId
1: &'tcx List<GenericArg<'tcx>>

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

Param(ParamTy)

Tuple Fields

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

Bound(DebruijnIndex, BoundTy)

Tuple Fields

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

Placeholder(Placeholder<BoundVar>)

Tuple Fields

A placeholder type - universally quantified higher-ranked type.

Infer(InferTy)

Tuple Fields

A type variable used during type checking.

Error(DelaySpanBugEmitted)

Tuple Fields

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

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

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: