Enum ra_ap_hir_ty::TyKind[][src]

pub enum TyKind {
    Adt(AdtId<Interner>, Substitution),
    AssociatedType(AssocTypeIdSubstitution),
    Scalar(Scalar),
    Tuple(usizeSubstitution),
    Array(Ty),
    Slice(Ty),
    Raw(MutabilityTy),
    Ref(MutabilityTy),
    OpaqueType(OpaqueTyIdSubstitution),
    FnDef(FnDefIdSubstitution),
    Str,
    Never,
    Closure(ClosureIdSubstitution),
    ForeignType(ForeignDefId),
    Function(FnPointer),
    Alias(AliasTy),
    Placeholder(PlaceholderIndex),
    BoundVar(BoundVar),
    InferenceVar(InferenceVarTyVariableKind),
    Dyn(DynTy),
    Unknown,
}

A type.

See also the TyKind enum in rustc (librustc/ty/sty.rs), which represents the same thing (but in a different way).

This should be cheap to clone.

Variants

Structures, enumerations and unions.

AssociatedType(AssocTypeIdSubstitution)

Represents an associated item like Iterator::Item. This is used when we have tried to normalize a projection like T::Item but couldn’t find a better representation. In that case, we generate an application type like (Iterator::Item)<T>.

Scalar(Scalar)

a scalar type like bool or u32

A tuple type. For example, (i32, bool).

Array(Ty)

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

Slice(Ty)

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

Raw(MutabilityTy)

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

Ref(MutabilityTy)

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

OpaqueType(OpaqueTyIdSubstitution)

This represents a placeholder for an opaque type in situations where we don’t know the hidden type (i.e. currently almost always). This is analogous to the AssociatedType type constructor. It is also used as the type of async block, with one type parameter representing the Future::Output type.

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}.

This includes tuple struct / enum variant constructors as well.

For example the type of bar here:

fn foo() -> i32 { 1 }
let bar = foo; // bar: fn() -> i32 {foo}
Str

The pointee of a string slice. Written as str.

Never

The never type !.

The type of a specific closure.

The closure signature is stored in a FnPtr type in the first type parameter.

ForeignType(ForeignDefId)

Represents a foreign type declared in external blocks.

Function(FnPointer)

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;
Alias(AliasTy)

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>
Placeholder(PlaceholderIndex)

A placeholder for a type parameter; for example, T in fn f<T>(x: T) {} when we’re type-checking the body of that function. In this situation, we know this stands for some type, but don’t know the exact type.

BoundVar(BoundVar)

A bound type variable. This is used in various places: when representing some polymorphic type like the type of function fn f<T>, the type parameters get turned into variables; during trait resolution, inference variables get turned into bound variables and back; and in Dyn the Self type is represented with a bound variable as well.

A type variable used during type checking.

Dyn(DynTy)

A trait object (dyn Trait or bare Trait in pre-2018 Rust).

The predicates are quantified over the Self type, i.e. Ty::Bound(0) represents the Self type inside the bounds. This is currently implicit; Chalk has the Binders struct to make it explicit, but it didn’t seem worth the overhead yet.

Unknown

A placeholder for a type which could not be computed; this is propagated to avoid useless error messages. Doubles as a placeholder where type variables are inserted before type checking, since we want to try to infer a better type here anyway – for the IDE use case, we want to try to infer as much as possible even in the presence of type errors.

Implementations

impl TyKind[src]

pub fn intern(self, _interner: &Interner) -> Ty[src]

Trait Implementations

impl Clone for TyKind[src]

impl Debug for TyKind[src]

impl Eq for TyKind[src]

impl Hash for TyKind[src]

impl PartialEq<TyKind> for TyKind[src]

impl StructuralEq for TyKind[src]

impl StructuralPartialEq for TyKind[src]

Auto Trait Implementations

impl RefUnwindSafe for TyKind

impl Send for TyKind

impl Sync for TyKind

impl Unpin for TyKind

impl UnwindSafe for TyKind

Blanket Implementations

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

impl<T> Any for T where
    T: Any

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

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

impl<T> Cast for T[src]

impl<T> CloneAny for T where
    T: Any + Clone

impl<Q, K> Equivalent<K> for Q where
    K: Borrow<Q> + ?Sized,
    Q: Eq + ?Sized
[src]

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

impl<T> Instrument for T[src]

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

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

type Owned = T

The resulting type after obtaining ownership.

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.

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.