@@ -26,6 +26,9 @@ pub mod prove_predicate;
2626use self :: prove_predicate:: ProvePredicate ;
2727pub mod subtype;
2828
29+ /// "Type ops" are used in NLL to perform some particular action and
30+ /// extract out the resulting region constraints (or an error if it
31+ /// cannot be completed).
2932pub trait TypeOp < ' gcx , ' tcx > : Sized + fmt:: Debug {
3033 type Output ;
3134
@@ -38,14 +41,23 @@ pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug {
3841 ) -> Fallible < ( Self :: Output , Option < Rc < Vec < QueryRegionConstraint < ' tcx > > > > ) > ;
3942}
4043
44+ /// "Query type ops" are type ops that are implemented using a
45+ /// [canonical query][c]. The `Self` type here contains the kernel of
46+ /// information needed to do the operation -- `TypeOp` is actually
47+ /// implemented for `ParamEnvAnd<Self>`, since we always need to bring
48+ /// along a parameter environment as well. For query type-ops, we will
49+ /// first canonicalize the key and then invoke the query on the tcx,
50+ /// which produces the resulting query region constraints.
51+ ///
52+ /// [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html
4153pub trait QueryTypeOp < ' gcx : ' tcx , ' tcx > :
4254 fmt:: Debug + Sized + TypeFoldable < ' tcx > + Lift < ' gcx >
4355{
4456 type QueryResult : TypeFoldable < ' tcx > + Lift < ' gcx > ;
4557
46- /// Either converts `self` directly into a `QueryResult` (for
47- /// simple cases) or into a `QueryKey` (for more complex cases
48- /// where we actually have work to do) .
58+ /// Give query the option for a simple fast path that never
59+ /// actually hits the tcx cache lookup etc. Return `Some(r)` with
60+ /// a final result or `None` to do the full path .
4961 fn try_fast_path (
5062 tcx : TyCtxt < ' _ , ' gcx , ' tcx > ,
5163 key : & ParamEnvAnd < ' tcx , Self > ,
0 commit comments