about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc/traits/query/type_op/eq.rs5
-rw-r--r--src/librustc/traits/query/type_op/mod.rs10
-rw-r--r--src/librustc/traits/query/type_op/normalize.rs5
-rw-r--r--src/librustc/traits/query/type_op/prove_predicate.rs5
-rw-r--r--src/librustc/traits/query/type_op/subtype.rs5
5 files changed, 27 insertions, 3 deletions
diff --git a/src/librustc/traits/query/type_op/eq.rs b/src/librustc/traits/query/type_op/eq.rs
index cc5f7215184..b70a5307097 100644
--- a/src/librustc/traits/query/type_op/eq.rs
+++ b/src/librustc/traits/query/type_op/eq.rs
@@ -26,6 +26,7 @@ impl<'tcx> Eq<'tcx> {
 }
 
 impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> {
+    type QueryKey = Self;
     type QueryResult = ();
 
     fn trivial_noop(self, _tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<Self::QueryResult, Self> {
@@ -36,6 +37,10 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Eq<'tcx> {
         }
     }
 
+    fn into_query_key(self) -> Self {
+        self
+    }
+
     fn param_env(&self) -> ty::ParamEnv<'tcx> {
         self.param_env
     }
diff --git a/src/librustc/traits/query/type_op/mod.rs b/src/librustc/traits/query/type_op/mod.rs
index 4addb6c027b..41d33338db4 100644
--- a/src/librustc/traits/query/type_op/mod.rs
+++ b/src/librustc/traits/query/type_op/mod.rs
@@ -103,18 +103,21 @@ pub trait TypeOp<'gcx, 'tcx>: Sized + fmt::Debug {
     }
 }
 
-pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: TypeFoldable<'tcx> + Lift<'gcx> {
+pub trait QueryTypeOp<'gcx: 'tcx, 'tcx>: fmt::Debug + Sized {
+    type QueryKey: TypeFoldable<'tcx> + Lift<'gcx>;
     type QueryResult: TypeFoldable<'tcx> + Lift<'gcx>;
 
     /// Micro-optimization: returns `Ok(x)` if we can trivially
     /// produce the output, else returns `Err(self)` back.
     fn trivial_noop(self, tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<Self::QueryResult, Self>;
 
+    fn into_query_key(self) -> Self::QueryKey;
+
     fn param_env(&self) -> ParamEnv<'tcx>;
 
     fn perform_query(
         tcx: TyCtxt<'_, 'gcx, 'tcx>,
-        canonicalized: Canonicalized<'gcx, Self>,
+        canonicalized: Canonicalized<'gcx, Self::QueryKey>,
     ) -> Fallible<CanonicalizedQueryResult<'gcx, Self::QueryResult>>;
 
     /// "Upcasts" a lifted query result (which is in the gcx lifetime)
@@ -149,7 +152,8 @@ where
         // `canonicalize_hr_query_hack` here because of things like
         // the subtype query, which go awry around `'static`
         // otherwise.
-        let (canonical_self, canonical_var_values) = infcx.canonicalize_hr_query_hack(&self);
+        let query_key = self.into_query_key();
+        let (canonical_self, canonical_var_values) = infcx.canonicalize_hr_query_hack(&query_key);
         let canonical_result = Q::perform_query(infcx.tcx, canonical_self)?;
 
         // FIXME: This is not the most efficient setup. The
diff --git a/src/librustc/traits/query/type_op/normalize.rs b/src/librustc/traits/query/type_op/normalize.rs
index 80bcc20f842..8c5bbe05616 100644
--- a/src/librustc/traits/query/type_op/normalize.rs
+++ b/src/librustc/traits/query/type_op/normalize.rs
@@ -33,6 +33,7 @@ impl<'gcx: 'tcx, 'tcx, T> super::QueryTypeOp<'gcx, 'tcx> for Normalize<'tcx, T>
 where
     T: Normalizable<'gcx, 'tcx>,
 {
+    type QueryKey = Self;
     type QueryResult = T;
 
     fn trivial_noop(self, _tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<T, Self> {
@@ -43,6 +44,10 @@ where
         }
     }
 
+    fn into_query_key(self) -> Self {
+        self
+    }
+
     fn param_env(&self) -> ParamEnv<'tcx> {
         self.param_env
     }
diff --git a/src/librustc/traits/query/type_op/prove_predicate.rs b/src/librustc/traits/query/type_op/prove_predicate.rs
index d2714803eae..1d02fe9a113 100644
--- a/src/librustc/traits/query/type_op/prove_predicate.rs
+++ b/src/librustc/traits/query/type_op/prove_predicate.rs
@@ -28,12 +28,17 @@ impl<'tcx> ProvePredicate<'tcx> {
 }
 
 impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for ProvePredicate<'tcx> {
+    type QueryKey = Self;
     type QueryResult = ();
 
     fn trivial_noop(self, _tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<Self::QueryResult, Self> {
         Err(self)
     }
 
+    fn into_query_key(self) -> Self {
+        self
+    }
+
     fn param_env(&self) -> ParamEnv<'tcx> {
         self.param_env
     }
diff --git a/src/librustc/traits/query/type_op/subtype.rs b/src/librustc/traits/query/type_op/subtype.rs
index 7bb1eda4eec..0842b78ce8b 100644
--- a/src/librustc/traits/query/type_op/subtype.rs
+++ b/src/librustc/traits/query/type_op/subtype.rs
@@ -30,6 +30,7 @@ impl<'tcx> Subtype<'tcx> {
 }
 
 impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> {
+    type QueryKey = Self;
     type QueryResult = ();
 
     fn trivial_noop(self, _tcx: TyCtxt<'_, 'gcx, 'tcx>) -> Result<(), Self> {
@@ -40,6 +41,10 @@ impl<'gcx: 'tcx, 'tcx> super::QueryTypeOp<'gcx, 'tcx> for Subtype<'tcx> {
         }
     }
 
+    fn into_query_key(self) -> Self {
+        self
+    }
+
     fn param_env(&self) -> ParamEnv<'tcx> {
         self.param_env
     }