diff options
| author | Niko Matsakis <niko@alum.mit.edu> | 2018-06-27 15:43:23 -0400 |
|---|---|---|
| committer | Niko Matsakis <niko@alum.mit.edu> | 2018-06-27 15:45:53 -0400 |
| commit | f0fdce31d962c3ca4f04f1729ec63af7781ed79f (patch) | |
| tree | c5932be6508e34ab7ea25f1326b0e3ab9d1e6a44 | |
| parent | 5fd3b2628087f254de51074bede5f17765dc1373 (diff) | |
| download | rust-f0fdce31d962c3ca4f04f1729ec63af7781ed79f.tar.gz rust-f0fdce31d962c3ca4f04f1729ec63af7781ed79f.zip | |
update comments
| -rw-r--r-- | src/librustc/traits/query/type_op/mod.rs | 18 |
1 files changed, 15 insertions, 3 deletions
diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs index 8a350d8570d..3dfa66cd41a 100644 --- a/src/librustc/traits/query/type_op/mod.rs +++ b/src/librustc/traits/query/type_op/mod.rs @@ -26,6 +26,9 @@ pub mod prove_predicate; use self::prove_predicate::ProvePredicate; pub mod subtype; +/// "Type ops" are used in NLL to perform some particular action and +/// extract out the resulting region constraints (or an error if it +/// cannot be completed). pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug { type Output; @@ -38,14 +41,23 @@ pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug { ) -> Fallible<(Self::Output, Option<Rc<Vec<QueryRegionConstraint<'tcx>>>>)>; } +/// "Query type ops" are type ops that are implemented using a +/// [canonical query][c]. The `Self` type here contains the kernel of +/// information needed to do the operation -- `TypeOp` is actually +/// implemented for `ParamEnvAnd<Self>`, since we always need to bring +/// along a parameter environment as well. For query type-ops, we will +/// first canonicalize the key and then invoke the query on the tcx, +/// which produces the resulting query region constraints. +/// +/// [c]: https://rust-lang-nursery.github.io/rustc-guide/traits/canonicalization.html pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized + TypeFoldable<'tcx> + Lift<'gcx> { type QueryResult: TypeFoldable<'tcx> + Lift<'gcx>; - /// Either converts `self` directly into a `QueryResult` (for - /// simple cases) or into a `QueryKey` (for more complex cases - /// where we actually have work to do). + /// Give query the option for a simple fast path that never + /// actually hits the tcx cache lookup etc. Return `Some(r)` with + /// a final result or `None` to do the full path. fn try_fast_path( tcx: TyCtxt<'_, 'gcx, 'tcx>, key: &ParamEnvAnd<'tcx, Self>, |
