@@ -119,23 +119,20 @@ or `fn(i32) -> i32` (with type aliases fully expanded).
119
119
120
120
## ` ty::Ty ` implementation
121
121
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
123
+ [ ` Interned<WithCachedTypeInfo<TyKind>> ` ] [ tykind ] .
124
+ You can ignore ` Interned ` in general; you will basically never access it explicitly.
125
+ We always hide them within ` Ty ` and skip over it via ` Deref ` impls or methods.
126
+ ` TyKind ` is a big enum
128
127
with variants to represent many different Rust types
129
128
(e.g. primitives, references, abstract data types, generics, lifetimes, etc).
130
- ` TyS ` also has 2 more fields, ` flags ` and ` outer_exclusive_binder ` . They
129
+ ` WithCachedTypeInfo ` has a few cached values like ` flags ` and ` outer_exclusive_binder ` . They
131
130
are 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
131
+ know, but they don’t come into the picture as much here. Finally, [ ` Interned ` ] ( ./memory.md ) allows
132
+ the ` ty::Ty ` to be a thin pointer-like
134
133
type. This allows us to do cheap comparisons for equality, along with the other
135
134
benefits of interning.
136
135
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
139
136
[ tykind ] : https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/ty/enum.TyKind.html
140
137
141
138
## Allocating and working with types
0 commit comments