@@ -225,16 +225,45 @@ pub enum TypeSort {
225
225
226
226
#[ derive( Clone , PartialEq , Eq , Hash , PartialOrd , Ord ) ]
227
227
pub enum Ty {
228
+ /// An "application" type is one that applies the set of type
229
+ /// arguments to some base type. For example, `Vec<u32>` would be
230
+ /// "applying" the parameters `[u32]` to the code type `Vec`.
231
+ /// This type is also used for base types like `u32` (which just apply
232
+ /// an empty list).
228
233
Apply ( ApplicationTy ) ,
234
+
235
+ /// A "projection" type corresponds to an (unnormalized)
236
+ /// projection like `<P0 as Trait<P1..Pn>>::Foo`. Note that the
237
+ /// trait and all its parameters are fully known.
229
238
Projection ( ProjectionTy ) ,
239
+
240
+ /// This is a variant of a projection in which the trait is
241
+ /// **not** known. It corresponds to a case where people write
242
+ /// `T::Item` without specifying the trait. We would then try to
243
+ /// figure out the trait by looking at all the traits that are in
244
+ /// scope.
230
245
UnselectedProjection ( UnselectedProjectionTy ) ,
246
+
247
+ /// A "higher-ranked" type. In the Rust surface syntax, this can
248
+ /// only be a funtion type (e.g., `for<'a> fn(&'a u32)`) or a dyn
249
+ /// type (e.g., `dyn for<'a> SomeTrait<&'a u32>`). However, in
250
+ /// Chalk's representation, we separate out the `for<'a>` part
251
+ /// from the underlying type, so technically we can represent
252
+ /// things like `for<'a> SomeStruct<'a>`, although that has no
253
+ /// meaning in Rust.
231
254
ForAll ( Box < QuantifiedTy > ) ,
232
255
233
- /// References the binding at the given depth (deBruijn index
234
- /// style).
256
+ /// References the binding at the given depth. The index is a [de
257
+ /// Bruijn index], so it counts back through the in-scope biners,
258
+ /// with 0 being the innermost binder. This is used in impls and
259
+ /// the like. For example, if we had a rule like `for<T> { (T:
260
+ /// Clone) :- (T: Copy) }`, then `T` would be represented as a
261
+ /// `BoundVar(0)` (as the `for` is the innermost binder).
262
+ ///
263
+ /// [de Bruijn index]: https://en.wikipedia.org/wiki/De_Bruijn_index
235
264
BoundVar ( usize ) ,
236
265
237
- /// Inference variable.
266
+ /// Inference variable defined in the current inference context .
238
267
InferenceVar ( InferenceVar ) ,
239
268
}
240
269
0 commit comments