Skip to main content

TypeKind

Enum TypeKind 

Source
pub enum TypeKind {
Show 14 variants Void, Bool, Int(IntKind), Float(FloatKind), Complex(FloatKind), BitInt { signed: bool, width: u32, }, Pointer(TypeId), Atomic(TypeId), Array { elem: TypeId, len: ArrayLen, }, Function(FunctionId), Vector { elem: TypeId, len: u32, }, Record(RecordId), Enum(EnumId), Typedef { name: Symbol, underlying: TypeId, },
}
Expand description

What a type is, with its qualifiers stripped off into Type::quals.

This is Copy and sixteen bytes, which is what lets it be the interning key directly. Function types and record types are the two that carry a variable amount of information, and both of them are an index into a table this crate owns.

Variants§

§

Void

void.

§

Bool

bool, which C23 spells without an underscore and which is one byte with two values.

§

Int(IntKind)

One of the standard integer types.

§

Float(FloatKind)

One of the real floating types.

§

Complex(FloatKind)

_Complex T for a real floating T.

§

BitInt

_BitInt(N) and unsigned _BitInt(N).

A distinct kind rather than an integer type with a width, because these do not take part in the integer promotions and folding them in with the standard types is how that rule gets forgotten.

Fields

§signed: bool

Whether the type is signed. A signed _BitInt(1) is legal and holds 0 and -1.

§width: u32

The declared width in bits, which is what the standard calls N.

§

Pointer(TypeId)

A pointer to the given type.

§

Atomic(TypeId)

_Atomic(T), which is a type and not a qualifier. See Qualifiers.

§

Array

An array of the given element type.

Fields

§elem: TypeId

The element type.

§len: ArrayLen

How many of them there are, which may be unknown.

§

Function(FunctionId)

A function type, whose parameter list is in this crate’s side table.

§

Vector

A GNU vector type, __attribute__((vector_size(n))).

Fields

§elem: TypeId

The element type, which must be a scalar.

§len: u32

How many elements there are.

§

Record(RecordId)

A struct or union, identified by its declaration rather than by its members.

§

Enum(EnumId)

An enum, identified by its declaration.

§

Typedef

A typedef name, which is sugar over whatever it was declared as.

Every semantic decision reads Types::canonical and never sees this; every diagnostic reads the type as written and sees nothing else, so the error says size_t rather than unsigned long. Compilers that drop the sugar produce messages nobody can act on, and compilers that decide on the sugar produce wrong answers, and both are common.

Fields

§name: Symbol

The name, for printing.

§underlying: TypeId

What it was declared as.

Trait Implementations§

Source§

impl Clone for TypeKind

Source§

fn clone(&self) -> TypeKind

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Copy for TypeKind

Source§

impl Debug for TypeKind

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Eq for TypeKind

Source§

impl Hash for TypeKind

Source§

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

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

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

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

impl PartialEq for TypeKind

Source§

fn eq(&self, other: &TypeKind) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for TypeKind

Auto Trait Implementations§

Blanket Implementations§

Source§

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

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

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

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

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

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

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

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

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

fn clone_into(&self, target: &mut T)

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

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

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.
Source§

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

Source§

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

The type returned in the event of a conversion error.
Source§

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

Performs the conversion.