@@ -119,23 +119,19 @@ or `fn(i32) -> i32` (with type aliases fully expanded).
119119
120120## ` ty::Ty ` implementation
121121
122- [ ` rustc_middle::ty::Ty ` ] [ ty_ty ] is actually a type alias to [ ` &TyS ` ] [ tys ] .
123- This type, which is short for "Type Structure", is where the main functionality is located.
124- You can ignore ` TyS ` struct in general; you will basically never access it explicitly.
125- We always pass it by reference using the ` Ty ` alias.
126- The only exception is to define inherent methods on types. In particular, ` TyS ` has a [ ` kind ` ] [ kind ]
127- field of type [ ` TyKind ` ] [ tykind ] , which represents the key type information. ` TyKind ` is a big enum
122+ [ ` rustc_middle::ty::Ty ` ] [ ty_ty ] is actually a wrapper around [ ` Interned<WithCachedTypeInfo<TyKind>> ` ] [ tykind ] .
123+ You can ignore ` Interned ` in general; you will basically never access it explicitly.
124+ We always hide them within ` Ty ` and skip over it via ` Deref ` impls or methods.
125+ ` TyKind ` is a big enum
128126with variants to represent many different Rust types
129127(e.g. primitives, references, abstract data types, generics, lifetimes, etc).
130- ` TyS ` also has 2 more fields, ` flags ` and ` outer_exclusive_binder ` . They
128+ ` WithCachedTypeInfo ` has a few cached values like ` flags ` and ` outer_exclusive_binder ` . They
131129are convenient hacks for efficiency and summarize information about the type that we may want to
132- know, but they don’t come into the picture as much here. Finally, ` ty::TyS ` s
133- are [ interned ] ( ./memory.md ) , so that the ` ty::Ty ` can be a thin pointer-like
130+ know, but they don’t come into the picture as much here. Finally, [ ` Interned ` ] ( ./memory.md ) allows
131+ the ` ty::Ty ` to be a thin pointer-like
134132type. This allows us to do cheap comparisons for equality, along with the other
135133benefits of interning.
136134
137- [ tys ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyS.html
138- [ kind ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/struct.TyS.html#structfield.kind
139135[ tykind ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.TyKind.html
140136
141137## Allocating and working with types
0 commit comments