about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-06-27 07:26:29 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-06-27 07:26:29 -0400
commitc6a7c6fc68049a1c7e862c595f326dedbc4e7ae6 (patch)
treeca092bf3b0630eacd2f2fe273b5a34667892a820 /src
parent1be4fffc24f0e348832bac2ed79d65febaf648bd (diff)
downloadrust-c6a7c6fc68049a1c7e862c595f326dedbc4e7ae6.tar.gz
rust-c6a7c6fc68049a1c7e862c595f326dedbc4e7ae6.zip
improve comments on `dropck_outlives`
Diffstat (limited to 'src')
-rw-r--r--src/librustc/traits/query/type_op/mod.rs6
-rw-r--r--src/librustc/traits/query/type_op/outlives.rs9
2 files changed, 15 insertions, 0 deletions
diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs
index 5875849f4f9..b55c0de5b0b 100644
--- a/src/librustc/traits/query/type_op/mod.rs
+++ b/src/librustc/traits/query/type_op/mod.rs
@@ -49,6 +49,12 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized {
 
     fn param_env(key: &Self::QueryKey) -> ParamEnv<'tcx>;
 
+    /// Performs the actual query with the canonicalized key -- the
+    /// real work happens here. This method is not given an `infcx`
+    /// because it shouldn't need one -- and if it had access to one,
+    /// it might do things like invoke `sub_regions`, which would be
+    /// bad, because it would create subregion relationships that are
+    /// not captured in the return value.
     fn perform_query(
         tcx: TyCtxt<'_, 'gcx, 'tcx>,
         canonicalized: Canonicalized<'gcx, Self::QueryKey>,
diff --git a/src/librustc/traits/query/type_op/outlives.rs b/src/librustc/traits/query/type_op/outlives.rs
index d429cccca96..369cefdfb47 100644
--- a/src/librustc/traits/query/type_op/outlives.rs
+++ b/src/librustc/traits/query/type_op/outlives.rs
@@ -52,6 +52,15 @@ where
         tcx: TyCtxt<'_, 'gcx, 'tcx>,
         canonicalized: Canonicalized<'gcx, Self::QueryKey>,
     ) -> Fallible<CanonicalizedQueryResult<'gcx, Self::QueryResult>> {
+        // Subtle: note that we are not invoking
+        // `infcx.at(...).dropck_outlives(...)` here, but rather the
+        // underlying `dropck_outlives` query. This same underlying
+        // query is also used by the
+        // `infcx.at(...).dropck_outlives(...)` fn. Avoiding the
+        // wrapper means we don't need an infcx in this code, which is
+        // good because the interface doesn't give us one (so that we
+        // know we are not registering any subregion relations or
+        // other things).
         tcx.dropck_outlives(canonicalized)
     }