pub enum TyKind<I>
where I: Interner,
{
Show 27 variants Bool, Char, Int(IntTy), Uint(UintTy), Float(FloatTy), Adt(<I as Interner>::AdtDef, <I as Interner>::GenericArgs), Foreign(<I as Interner>::DefId), Str, Array(<I as Interner>::Ty, <I as Interner>::Const), Slice(<I as Interner>::Ty), RawPtr(TypeAndMut<I>), Ref(<I as Interner>::Region, <I as Interner>::Ty, Mutability), FnDef(<I as Interner>::DefId, <I as Interner>::GenericArgs), FnPtr(<I as Interner>::PolyFnSig), Dynamic(<I as Interner>::BoundExistentialPredicates, <I as Interner>::Region, DynKind), Closure(<I as Interner>::DefId, <I as Interner>::GenericArgs), CoroutineClosure(<I as Interner>::DefId, <I as Interner>::GenericArgs), Coroutine(<I as Interner>::DefId, <I as Interner>::GenericArgs), CoroutineWitness(<I as Interner>::DefId, <I as Interner>::GenericArgs), Never, Tuple(<I as Interner>::Tys), Alias(AliasKind, <I as Interner>::AliasTy), Param(<I as Interner>::ParamTy), Bound(DebruijnIndex, <I as Interner>::BoundTy), Placeholder(<I as Interner>::PlaceholderTy), Infer(InferTy), Error(<I as Interner>::ErrorGuaranteed),
}
Expand description

Defines the kinds of types used by the type system.

Types written by the user start out as hir::TyKind and get converted to this representation using AstConv::ast_ty_to_ty.

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.

§

Uint(UintTy)

A primitive unsigned integer type. For example, u32.

§

Float(FloatTy)

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

§

Adt(<I as Interner>::AdtDef, <I as Interner>::GenericArgs)

Algebraic data types (ADT). For example: structures, enumerations and unions.

For example, the type List<i32> would be represented using the AdtDef for struct List<T> and the args [i32].

Note that generic parameters in fields only get lazily instantiated by using something like adt_def.all_fields().map(|field| field.ty(tcx, args)).

§

Foreign(<I as Interner>::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(<I as Interner>::Ty, <I as Interner>::Const)

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

§

Slice(<I as Interner>::Ty)

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

§

RawPtr(TypeAndMut<I>)

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

§

Ref(<I as Interner>::Region, <I as Interner>::Ty, Mutability)

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

§

FnDef(<I as Interner>::DefId, <I as Interner>::GenericArgs)

The anonymous type of a function declaration/definition. Each function has a unique type.

For the function fn foo() -> i32 { 3 } this type would be shown to the user as fn() -> i32 {foo}.

For example the type of bar here:

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

FnPtr(<I as Interner>::PolyFnSig)

A pointer to a function. Written as fn() -> i32.

Note that both functions and closures start out as either FnDef or Closure which can be then be coerced to this variant.

For example the type of bar here:

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

Dynamic(<I as Interner>::BoundExistentialPredicates, <I as Interner>::Region, DynKind)

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

§

Closure(<I as Interner>::DefId, <I as Interner>::GenericArgs)

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

Closure args contain both the - potentially instantiated - generic parameters of its parent and some synthetic parameters. See the documentation for ClosureArgs for more details.

§

CoroutineClosure(<I as Interner>::DefId, <I as Interner>::GenericArgs)

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

Coroutine-closure args contain both the - potentially instantiated - generic parameters of its parent and some synthetic parameters. See the documentation for CoroutineClosureArgs for more details.

§

Coroutine(<I as Interner>::DefId, <I as Interner>::GenericArgs)

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

For more info about coroutine args, visit the documentation for CoroutineArgs.

§

CoroutineWitness(<I as Interner>::DefId, <I as Interner>::GenericArgs)

A type representing the types stored inside a coroutine. This should only appear as part of the CoroutineArgs.

Unlike upvars, the witness can reference lifetimes from inside of the coroutine itself. To deal with them in the type of the coroutine, we convert them to higher ranked lifetimes bound by the witness itself.

This contains the DefId and the GenericArgsRef of the coroutine. The actual witness types are computed on MIR by the mir_coroutine_witnesses query.

Looking at the following example, the witness for this coroutine may end up as something like for<'a> [Vec<i32>, &'a Vec<i32>]:

#![feature(coroutines)]
|a| {
    let x = &vec![3];
    yield a;
    yield x[0];
}
§

Never

The never type !.

§

Tuple(<I as Interner>::Tys)

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

§

Alias(AliasKind, <I as Interner>::AliasTy)

A projection, opaque type, weak type alias, or inherent associated type. All of these types are represented as pairs of def-id and args, and can be normalized, so they are grouped conceptually.

§

Param(<I as Interner>::ParamTy)

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

§

Bound(DebruijnIndex, <I as Interner>::BoundTy)

Bound type variable, used to represent the 'a in for<'a> fn(&'a ()).

For canonical queries, we replace inference variables with bound variables, so e.g. when checking whether &'_ (): Trait<_> holds, we canonicalize that to for<'a, T> &'a (): Trait<T> and then convert the introduced bound variables back to inference variables in a new inference context when inside of the query.

It is conventional to render anonymous bound types like ^N or ^D_N, where N is the bound variable’s anonymous index into the binder, and D is the debruijn index, or totally omitted if the debruijn index is zero.

See the rustc-dev-guide for more details about higher-ranked trait bounds and canonical queries.

§

Placeholder(<I as Interner>::PlaceholderTy)

A placeholder type, used during higher ranked subtyping to instantiate bound variables.

It is conventional to render anonymous placeholer types like !N or !U_N, where N is the placeholder variable’s anonymous index (which corresponds to the bound variable’s index from the binder from which it was instantiated), and U is the universe index in which it is instantiated, or totally omitted if the universe index is zero.

§

Infer(InferTy)

A type variable used during type checking.

Similar to placeholders, inference variables also live in a universe to correctly deal with higher ranked types. Though unlike placeholders, that universe is stored in the InferCtxt instead of directly inside of the type.

§

Error(<I as Interner>::ErrorGuaranteed)

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

Implementations§

source§

impl<I> TyKind<I>
where I: Interner,

source

pub fn is_primitive(&self) -> bool

Trait Implementations§

source§

impl<I> Clone for TyKind<I>
where I: Interner,

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> Debug for TyKind<I>
where I: Interner,

source§

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

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

impl<I> DebugWithInfcx<I> for TyKind<I>
where I: Interner,

source§

fn fmt<Infcx>( this: WithInfcx<'_, Infcx, &TyKind<I>>, f: &mut Formatter<'_> ) -> Result<(), Error>
where Infcx: InferCtxtLike<Interner = I>,

source§

impl<I, __D> Decodable<__D> for TyKind<I>
where I: Interner, __D: TyDecoder<I = I>, <I as Interner>::AdtDef: Decodable<__D>, <I as Interner>::GenericArgs: Decodable<__D>, <I as Interner>::DefId: Decodable<__D>, <I as Interner>::Ty: Decodable<__D>, <I as Interner>::Const: Decodable<__D>, TypeAndMut<I>: Decodable<__D>, <I as Interner>::Region: Decodable<__D>, <I as Interner>::PolyFnSig: Decodable<__D>, <I as Interner>::BoundExistentialPredicates: Decodable<__D>, <I as Interner>::Tys: Decodable<__D>, <I as Interner>::AliasTy: Decodable<__D>, <I as Interner>::ParamTy: Decodable<__D>, <I as Interner>::BoundTy: Decodable<__D>, <I as Interner>::PlaceholderTy: Decodable<__D>, <I as Interner>::ErrorGuaranteed: Decodable<__D>,

source§

fn decode(__decoder: &mut __D) -> TyKind<I>

source§

impl<I, __E> Encodable<__E> for TyKind<I>
where I: Interner, __E: TyEncoder<I = I>, <I as Interner>::AdtDef: Encodable<__E>, <I as Interner>::GenericArgs: Encodable<__E>, <I as Interner>::DefId: Encodable<__E>, <I as Interner>::Ty: Encodable<__E>, <I as Interner>::Const: Encodable<__E>, TypeAndMut<I>: Encodable<__E>, <I as Interner>::Region: Encodable<__E>, <I as Interner>::PolyFnSig: Encodable<__E>, <I as Interner>::BoundExistentialPredicates: Encodable<__E>, <I as Interner>::Tys: Encodable<__E>, <I as Interner>::AliasTy: Encodable<__E>, <I as Interner>::ParamTy: Encodable<__E>, <I as Interner>::BoundTy: Encodable<__E>, <I as Interner>::PlaceholderTy: Encodable<__E>, <I as Interner>::ErrorGuaranteed: Encodable<__E>,

source§

fn encode(&self, __encoder: &mut __E)

source§

impl<I> Hash for TyKind<I>
where I: Interner,

source§

fn hash<__HI>(&self, __state: &mut __HI)
where __HI: Hasher,

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, __CTX> HashStable<__CTX> for TyKind<I>
where I: Interner, <I as Interner>::AdtDef: HashStable<__CTX>, <I as Interner>::GenericArgs: HashStable<__CTX>, <I as Interner>::DefId: HashStable<__CTX>, <I as Interner>::Ty: HashStable<__CTX>, <I as Interner>::Const: HashStable<__CTX>, TypeAndMut<I>: HashStable<__CTX>, <I as Interner>::Region: HashStable<__CTX>, <I as Interner>::PolyFnSig: HashStable<__CTX>, <I as Interner>::BoundExistentialPredicates: HashStable<__CTX>, <I as Interner>::Tys: HashStable<__CTX>, <I as Interner>::AliasTy: HashStable<__CTX>, <I as Interner>::ParamTy: HashStable<__CTX>, <I as Interner>::BoundTy: HashStable<__CTX>, <I as Interner>::PlaceholderTy: HashStable<__CTX>, <I as Interner>::ErrorGuaranteed: HashStable<__CTX>,

source§

fn hash_stable(&self, __hcx: &mut __CTX, __hasher: &mut StableHasher)

source§

impl<I> Ord for TyKind<I>
where I: Interner,

source§

fn cmp(&self, other: &TyKind<I>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized + PartialOrd,

Restrict a value to a certain interval. Read more
source§

impl<I> PartialEq for TyKind<I>
where I: Interner,

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> PartialOrd for TyKind<I>
where I: Interner,

source§

fn partial_cmp(&self, other: &TyKind<I>) -> Option<Ordering>

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

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

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

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

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

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

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

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

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

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

source§

impl<I> Eq for TyKind<I>
where I: Interner,

Auto Trait Implementations§

§

impl<I> DynSend for TyKind<I>

§

impl<I> DynSync for TyKind<I>

§

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

source§

const ALIGN: Alignment = _

Alignment of Self.
source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
§

impl<T> AnyEq for T
where T: Any + PartialEq,

§

fn equals(&self, other: &(dyn Any + 'static)) -> bool

§

fn as_any(&self) -> &(dyn Any + 'static)

source§

impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for T
where T: Copy,

source§

fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T

source§

fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T> ) -> &'a mut [T]

source§

impl<'tcx, T> ArenaAllocatable<'tcx, IsCopy> for T
where T: Copy,

source§

fn allocate_on<'a>(self, arena: &'a Arena<'tcx>) -> &'a mut T

source§

fn allocate_from_iter<'a>( arena: &'a Arena<'tcx>, iter: impl IntoIterator<Item = T> ) -> &'a mut [T]

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, R> CollectAndApply<T, R> for T

source§

fn collect_and_apply<I, F>(iter: I, f: F) -> R
where I: Iterator<Item = T>, F: FnOnce(&[T]) -> R,

Equivalent to f(&iter.collect::<Vec<_>>()).

§

type Output = R

§

impl<Q, K> Comparable<K> for Q
where Q: Ord + ?Sized, K: Borrow<Q> + ?Sized,

§

fn compare(&self, key: &K) -> Ordering

Compare self to key and return their ordering.
source§

impl<Tcx, T> DepNodeParams<Tcx> for T
where Tcx: DepContext, T: for<'a> HashStable<StableHashingContext<'a>> + Debug,

source§

default fn fingerprint_style() -> FingerprintStyle

source§

default fn to_fingerprint(&self, tcx: Tcx) -> Fingerprint

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).
source§

default fn to_debug_str(&self, _: Tcx) -> String

source§

default fn recover(_: Tcx, _: &DepNode) -> Option<T>

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.
source§

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

source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

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

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

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

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
§

impl<T> Filterable for T

§

fn filterable( self, filter_name: &'static str ) -> RequestFilterDataProvider<T, fn(_: DataRequest<'_>) -> bool>

Creates a filterable data provider with the given name for debugging. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

source§

impl<T> Instrument for T

source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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<P> IntoQueryParam<P> for P

source§

impl<T> MaybeResult<T> for T

§

type Error = !

source§

fn from(_: Result<T, <T as MaybeResult<T>>::Error>) -> T

source§

fn to_result(self) -> Result<T, <T as MaybeResult<T>>::Error>

§

impl<T> Pointable for T

§

const ALIGN: usize = _

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
source§

impl<T> Same for T

§

type Output = T

Should always be Self
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<'tcx, T> ToPredicate<'tcx, T> for T

source§

fn to_predicate(self, _tcx: TyCtxt<'tcx>) -> T

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

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

source§

impl<Tcx, T> Value<Tcx> for T
where Tcx: DepContext,

source§

default fn from_cycle_error( tcx: Tcx, cycle_error: &CycleError, _guar: ErrorGuaranteed ) -> T

source§

impl<T> WithSubscriber for T

source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
source§

impl<'a, T> Captures<'a> for T
where T: ?Sized,

§

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> MaybeSendSync for T
where T: Send + Sync,

Layout§

Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.