about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-06-27 07:02:37 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-06-27 07:02:37 -0400
commit59ea17ed3f598791e241c7e7629c4d67f51d436e (patch)
tree8e94323d8def22efd837f7f30ec895255b3829fc
parentd69551243756fff4c81d857177bffbb0f6fcb9ff (diff)
downloadrust-59ea17ed3f598791e241c7e7629c4d67f51d436e.tar.gz
rust-59ea17ed3f598791e241c7e7629c4d67f51d436e.zip
rename `upcast` to `cast_to_tcx_lifetime` and improve comment
-rw-r--r--src/librustc/traits/query/type_op/eq.rs2
-rw-r--r--src/librustc/traits/query/type_op/mod.rs15
-rw-r--r--src/librustc/traits/query/type_op/normalize.rs14
-rw-r--r--src/librustc/traits/query/type_op/outlives.rs2
-rw-r--r--src/librustc/traits/query/type_op/prove_predicate.rs2
-rw-r--r--src/librustc/traits/query/type_op/subtype.rs2
6 files changed, 21 insertions, 16 deletions
diff --git a/src/librustc/traits/query/type_op/eq.rs b/src/librustc/traits/query/type_op/eq.rs
index 04d256a93e1..fc5d174fff4 100644
--- a/src/librustc/traits/query/type_op/eq.rs
+++ b/src/librustc/traits/query/type_op/eq.rs
@@ -48,7 +48,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> {
         tcx.type_op_eq(canonicalized)
     }
 
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         v: &'a CanonicalizedQueryResult<'gcx, ()>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> {
         v
diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs
index 16280885c12..5875849f4f9 100644
--- a/src/librustc/traits/query/type_op/mod.rs
+++ b/src/librustc/traits/query/type_op/mod.rs
@@ -54,14 +54,19 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized {
         canonicalized: Canonicalized<'gcx, Self::QueryKey>,
     ) -> Fallible<CanonicalizedQueryResult<'gcx, Self::QueryResult>>;
 
-    /// "Upcasts" a lifted query result (which is in the gcx lifetime)
+    /// Casts a lifted query result (which is in the gcx lifetime)
     /// into the tcx lifetime. This is always just an identity cast,
-    /// but the generic code does't realize it, so we have to push the
-    /// operation into the impls that know more specifically what
+    /// but the generic code doesn't realize it -- put another way, in
+    /// the generic code, we have a `Lifted<'gcx, Self::QueryResult>`
+    /// and we want to convert that to a `Self::QueryResult`. This is
+    /// not a priori valid, so we can't do it -- but in practice, it
+    /// is always a no-op (e.g., the lifted form of a type,
+    /// `Ty<'gcx>`, is a subtype of `Ty<'tcx>`). So we have to push
+    /// the operation into the impls that know more specifically what
     /// `QueryResult` is. This operation would (maybe) be nicer with
     /// something like HKTs or GATs, since then we could make
     /// `QueryResult` parametric and `'gcx` and `'tcx` etc.
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         lifted_query_result: &'a CanonicalizedQueryResult<'gcx, Self::QueryResult>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self::QueryResult>>;
 
@@ -80,7 +85,7 @@ pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized {
                 let (canonical_self, canonical_var_values) =
                     infcx.canonicalize_hr_query_hack(&query_key);
                 let canonical_result = Self::perform_query(infcx.tcx, canonical_self)?;
-                let canonical_result = Self::upcast_result(&canonical_result);
+                let canonical_result = Self::cast_to_tcx_lifetime(&canonical_result);
 
                 let param_env = Self::param_env(&query_key);
 
diff --git a/src/librustc/traits/query/type_op/normalize.rs b/src/librustc/traits/query/type_op/normalize.rs
index b72c887ba50..5e3a23a5f30 100644
--- a/src/librustc/traits/query/type_op/normalize.rs
+++ b/src/librustc/traits/query/type_op/normalize.rs
@@ -55,10 +55,10 @@ where
         T::type_op_method(tcx, canonicalized)
     }
 
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         v: &'a CanonicalizedQueryResult<'gcx, T>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, T>> {
-        T::upcast_result(v)
+        T::cast_to_tcx_lifetime(v)
     }
 }
 
@@ -70,7 +70,7 @@ pub trait Normalizable<'gcx, 'tcx>: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx>
 
     /// Convert from the `'gcx` (lifted) form of `Self` into the `tcx`
     /// form of `Self`.
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         v: &'a CanonicalizedQueryResult<'gcx, Self>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>>;
 }
@@ -86,7 +86,7 @@ where
         tcx.type_op_normalize_ty(canonicalized)
     }
 
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         v: &'a CanonicalizedQueryResult<'gcx, Self>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> {
         v
@@ -104,7 +104,7 @@ where
         tcx.type_op_normalize_predicate(canonicalized)
     }
 
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         v: &'a CanonicalizedQueryResult<'gcx, Self>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> {
         v
@@ -122,7 +122,7 @@ where
         tcx.type_op_normalize_poly_fn_sig(canonicalized)
     }
 
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         v: &'a CanonicalizedQueryResult<'gcx, Self>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> {
         v
@@ -140,7 +140,7 @@ where
         tcx.type_op_normalize_fn_sig(canonicalized)
     }
 
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         v: &'a CanonicalizedQueryResult<'gcx, Self>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self>> {
         v
diff --git a/src/librustc/traits/query/type_op/outlives.rs b/src/librustc/traits/query/type_op/outlives.rs
index 0254b901a8c..d429cccca96 100644
--- a/src/librustc/traits/query/type_op/outlives.rs
+++ b/src/librustc/traits/query/type_op/outlives.rs
@@ -55,7 +55,7 @@ where
         tcx.dropck_outlives(canonicalized)
     }
 
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         lifted_query_result: &'a CanonicalizedQueryResult<'gcx, Self::QueryResult>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, Self::QueryResult>> {
         lifted_query_result
diff --git a/src/librustc/traits/query/type_op/prove_predicate.rs b/src/librustc/traits/query/type_op/prove_predicate.rs
index b06ad32ff22..c610421e68a 100644
--- a/src/librustc/traits/query/type_op/prove_predicate.rs
+++ b/src/librustc/traits/query/type_op/prove_predicate.rs
@@ -46,7 +46,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> {
         tcx.type_op_prove_predicate(canonicalized)
     }
 
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         v: &'a CanonicalizedQueryResult<'gcx, ()>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> {
         v
diff --git a/src/librustc/traits/query/type_op/subtype.rs b/src/librustc/traits/query/type_op/subtype.rs
index bdc7dd9589b..8bb773b4c80 100644
--- a/src/librustc/traits/query/type_op/subtype.rs
+++ b/src/librustc/traits/query/type_op/subtype.rs
@@ -52,7 +52,7 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> {
         tcx.type_op_subtype(canonicalized)
     }
 
-    fn upcast_result(
+    fn cast_to_tcx_lifetime(
         v: &'a CanonicalizedQueryResult<'gcx, ()>,
     ) -> &'a Canonical<'tcx, QueryResult<'tcx, ()>> {
         v