@@ -26,6 +26,9 @@ pub mod prove_predicate;
26
26
use self :: prove_predicate:: ProvePredicate ;
27
27
pub mod subtype;
28
28
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).
29
32
pub trait TypeOp < ' gcx , ' tcx > : Sized + fmt:: Debug {
30
33
type Output ;
31
34
@@ -38,14 +41,23 @@ pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug {
38
41
) -> Fallible < ( Self :: Output , Option < Rc < Vec < QueryRegionConstraint < ' tcx > > > > ) > ;
39
42
}
40
43
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
41
53
pub trait QueryTypeOp < ' gcx : ' tcx , ' tcx > :
42
54
fmt:: Debug + Sized + TypeFoldable < ' tcx > + Lift < ' gcx >
43
55
{
44
56
type QueryResult : TypeFoldable < ' tcx > + Lift < ' gcx > ;
45
57
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 .
49
61
fn try_fast_path (
50
62
tcx : TyCtxt < ' _ , ' gcx , ' tcx > ,
51
63
key : & ParamEnvAnd < ' tcx , Self > ,
0 commit comments