Enum chalk_ir::TyKind

source ·
pub enum TyKind<I: Interner> {
Show 23 variants Adt(AdtId<I>, Substitution<I>), AssociatedType(AssocTypeId<I>, Substitution<I>), Scalar(Scalar), Tuple(usize, Substitution<I>), Array(Ty<I>, Const<I>), Slice(Ty<I>), Raw(Mutability, Ty<I>), Ref(Mutability, Lifetime<I>, Ty<I>), OpaqueType(OpaqueTyId<I>, Substitution<I>), FnDef(FnDefId<I>, Substitution<I>), Str, Never, Closure(ClosureId<I>, Substitution<I>), Coroutine(CoroutineId<I>, Substitution<I>), CoroutineWitness(CoroutineId<I>, Substitution<I>), Foreign(ForeignDefId<I>), Error, Placeholder(PlaceholderIndex), Dyn(DynTy<I>), Alias(AliasTy<I>), Function(FnPointer<I>), BoundVar(BoundVar), InferenceVar(InferenceVar, TyVariableKind),
}
Expand description

Type data, which holds the actual type information.

Variants§

§

Adt(AdtId<I>, Substitution<I>)

Abstract data types, i.e., structs, unions, or enumerations. For example, a type like Vec<T>.

§

AssociatedType(AssocTypeId<I>, Substitution<I>)

an associated type like Iterator::Item; see AssociatedType for details

§

Scalar(Scalar)

a scalar type like bool or u32

§

Tuple(usize, Substitution<I>)

a tuple of the given arity

§

Array(Ty<I>, Const<I>)

an array type like [T; N]

§

Slice(Ty<I>)

a slice type like [T]

§

Raw(Mutability, Ty<I>)

a raw pointer type like *const T or *mut T

§

Ref(Mutability, Lifetime<I>, Ty<I>)

a reference type like &T or &mut T

§

OpaqueType(OpaqueTyId<I>, Substitution<I>)

a placeholder for opaque types like impl Trait

§

FnDef(FnDefId<I>, Substitution<I>)

a function definition

§

Str

the string primitive type

§

Never

the never type !

§

Closure(ClosureId<I>, Substitution<I>)

A closure.

§

Coroutine(CoroutineId<I>, Substitution<I>)

A coroutine.

§

CoroutineWitness(CoroutineId<I>, Substitution<I>)

A coroutine witness.

§

Foreign(ForeignDefId<I>)

foreign types

§

Error

This can be used to represent an error, e.g. during name resolution of a type. Chalk itself will not produce this, just pass it through when given.

§

Placeholder(PlaceholderIndex)

instantiated from a universally quantified type, e.g., from forall<T> { .. }. Stands in as a representative of “some unknown type”.

§

Dyn(DynTy<I>)

A “dyn” type is a trait object type created via the “dyn Trait” syntax. In the chalk parser, the traits that the object represents is parsed as a QuantifiedInlineBound, and is then changed to a list of where clauses during lowering.

See the Opaque variant for a discussion about the use of binders here.

§

Alias(AliasTy<I>)

An “alias” type represents some form of type alias, such as:

  • An associated type projection like <T as Iterator>::Item
  • impl Trait types
  • Named type aliases like type Foo<X> = Vec<X>
§

Function(FnPointer<I>)

A function type such as for<'a> fn(&'a u32). Note that “higher-ranked” types (starting with for<>) are either function types or dyn types, and do not appear otherwise in Rust surface syntax.

§

BoundVar(BoundVar)

References the binding at the given depth. The index is a [de Bruijn index], so it counts back through the in-scope binders.

§

InferenceVar(InferenceVar, TyVariableKind)

Inference variable defined in the current inference context.

Implementations§

source§

impl<I: Interner> TyKind<I>

source

pub fn debug(&self, interner: I) -> TyKindDebug<'_, I>

Show debug output for the application type.

source§

impl<I: Interner> TyKind<I>

source

pub fn intern(self, interner: I) -> Ty<I>

Casts the type data to a type.

source

pub fn compute_flags(&self, interner: I) -> TypeFlags

Compute type flags for a TyKind

Trait Implementations§

source§

impl<I: Interner> CastTo<TyKind<I>> for AliasTy<I>

source§

fn cast_to(self, _interner: I) -> TyKind<I>

Cast a value to type T.
source§

impl<I: Interner> CastTo<TyKind<I>> for TyKind<I>

source§

fn cast_to(self, _interner: <TyKind<I> as HasInterner>::Interner) -> TyKind<I>

Cast a value to type T.
source§

impl<I: Clone + Interner> Clone for TyKind<I>

source§

fn clone(&self) -> TyKind<I>

Returns a copy of the value. Read more
1.0.0 · source§

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

Performs copy-assignment from source. Read more
source§

impl<I: Interner> Debug for TyKind<I>

source§

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

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

impl<I: Interner> HasInterner for TyKind<I>

§

type Interner = I

The interner associated with the type.
source§

impl<I: Hash + Interner> Hash for TyKind<I>

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<I: PartialEq + Interner> PartialEq for TyKind<I>

source§

fn eq(&self, other: &TyKind<I>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<I: Interner> Copy for TyKind<I>

source§

impl<I: Eq + Interner> Eq for TyKind<I>

source§

impl<I: Interner> StructuralEq for TyKind<I>

source§

impl<I: Interner> StructuralPartialEq for TyKind<I>

Auto Trait Implementations§

§

impl<I> RefUnwindSafe for TyKind<I>

§

impl<I> Send for TyKind<I>

§

impl<I> Sync for TyKind<I>

§

impl<I> Unpin for TyKind<I>

§

impl<I> UnwindSafe for TyKind<I>

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> Cast for T

source§

fn cast<U>(self, interner: U::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
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,

§

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>,

§

type Error = Infallible

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>,

§

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.