TyKind in rustc_ast::ast - Rust (original) (raw)
pub enum TyKind {
Show 20 variants Slice(Box<Ty>),
Array(Box<Ty>, AnonConst),
Ptr(MutTy),
Ref(Option<Lifetime>, MutTy),
PinnedRef(Option<Lifetime>, MutTy),
FnPtr(Box<FnPtrTy>),
UnsafeBinder(Box<UnsafeBinderTy>),
Never,
Tup(ThinVec<Box<Ty>>),
Path(Option<Box<QSelf>>, Path),
TraitObject(GenericBounds, TraitObjectSyntax),
ImplTrait(NodeId, GenericBounds),
Paren(Box<Ty>),
Infer,
ImplicitSelf,
MacCall(Box<MacCall>),
CVarArgs,
Pat(Box<Ty>, Box<TyPat>),
Dummy,
Err(ErrorGuaranteed),
}Expand description
The various kinds of type recognized by the compiler.
A variable-length slice ([T]).
A fixed length array ([T; n]).
A raw pointer (*const T or *mut T).
A reference (&'a T or &'a mut T).
A pinned reference (&'a pin const T or &'a pin mut T).
Desugars into Pin<&'a T> or Pin<&'a mut T>.
A function pointer type (e.g., fn(usize) -> bool).
An unsafe existential lifetime binder (e.g., unsafe<'a> &'a ()).
The never type (!).
A tuple ((A, B, C, D,...)).
A path (module::module::...::Type), optionally “qualified”, e.g., <Vec<T> as SomeTrait>::SomeType.
Type parameters are stored in the Path itself.
A trait object type Bound1 + Bound2 + Bound3where Bound is a trait or a lifetime.
An impl Bound1 + Bound2 + Bound3 type where Bound is a trait or a lifetime.
The NodeId exists to prevent lowering from having to generate NodeIds on the fly, which would complicate the generation of opaque type Foo = impl Trait items significantly.
No-op; kept solely so that we can pretty-print faithfully.
This means the type should be inferred instead of it having been specified. This can appear anywhere in a type.
Inferred type of a self or &self argument in a method.
A macro in the type position.
Placeholder for a va_list.
Pattern types like pattern_type!(u32 is 1..=), which is the same as NonZero<u32>, just as part of the type system.
Sometimes we need a dummy value when no error has occurred.
Placeholder for a kind that has failed to be defined.
Returns true if this type is considered a scalar primitive (e.g.,i32, u8, bool, etc).
This check is based on symbol equality and does not remove any path prefixes or references. If a type alias or shadowing is present (e.g., type i32 = CustomType;), this method will still return truefor i32, even though it may not refer to the primitive type.
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: 40 bytes
Size for each variant:
Slice: 15 bytesArray: 31 bytesPtr: 23 bytesRef: 39 bytesPinnedRef: 39 bytesFnPtr: 15 bytesUnsafeBinder: 15 bytesNever: 0 bytesTup: 15 bytesPath: 39 bytesTraitObject: 31 bytesImplTrait: 31 bytesParen: 15 bytesInfer: 0 bytesImplicitSelf: 0 bytesMacCall: 15 bytesCVarArgs: 0 bytesPat: 23 bytesDummy: 0 bytesErr: 0 bytes