about summary refs log tree commit diff
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-06-08 09:34:31 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-06-26 10:49:24 -0400
commitbebd3ff6666d3e3f9bf458c5fab6c71c038db54f (patch)
tree825b4da15552638797c538dbcdda2c009cb2bca0
parentdfd33f593218aa47030e3d9abc12bf19c3c7525d (diff)
downloadrust-bebd3ff6666d3e3f9bf458c5fab6c71c038db54f.tar.gz
rust-bebd3ff6666d3e3f9bf458c5fab6c71c038db54f.zip
extract a helper for `make_query_result` that skips canonicalization
-rw-r--r--src/librustc/infer/canonical/query_result.rs38
1 files changed, 27 insertions, 11 deletions
diff --git a/src/librustc/infer/canonical/query_result.rs b/src/librustc/infer/canonical/query_result.rs
index aff9136bad0..190a6c18ff8 100644
--- a/src/librustc/infer/canonical/query_result.rs
+++ b/src/librustc/infer/canonical/query_result.rs
@@ -67,10 +67,33 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
         T: Debug,
         QueryResult<'tcx, T>: Canonicalize<'gcx, 'tcx>,
     {
+        let query_result = self.make_query_result(inference_vars, answer, fulfill_cx)?;
+        let (canonical_result, _) = self.canonicalize_response(&query_result);
+
+        debug!(
+            "make_canonicalized_query_result: canonical_result = {:#?}",
+            canonical_result
+        );
+
+        Ok(canonical_result)
+    }
+
+    /// Helper for `make_canonicalized_query_result` that does
+    /// everything up until the final canonicalization.
+    fn make_query_result<T>(
+        &self,
+        inference_vars: CanonicalVarValues<'tcx>,
+        answer: T,
+        fulfill_cx: &mut FulfillmentContext<'tcx>,
+    ) -> Result<QueryResult<'tcx, T>, NoSolution>
+    where
+        T: Debug,
+        QueryResult<'tcx, T>: Canonicalize<'gcx, 'tcx>,
+    {
         let tcx = self.tcx;
 
         debug!(
-            "make_query_response(\
+            "make_query_result(\
              inference_vars={:?}, \
              answer={:?})",
             inference_vars, answer,
@@ -85,7 +108,7 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
 
         if !true_errors.is_empty() {
             // FIXME -- we don't indicate *why* we failed to solve
-            debug!("make_query_response: true_errors={:#?}", true_errors);
+            debug!("make_query_result: true_errors={:#?}", true_errors);
             return Err(NoSolution);
         }
 
@@ -144,19 +167,12 @@ impl<'cx, 'gcx, 'tcx> InferCtxt<'cx, 'gcx, 'tcx> {
             Certainty::Ambiguous
         };
 
-        let (canonical_result, _) = self.canonicalize_response(&QueryResult {
+        Ok(QueryResult {
             var_values: inference_vars,
             region_constraints,
             certainty,
             value: answer,
-        });
-
-        debug!(
-            "make_query_response: canonical_result = {:#?}",
-            canonical_result
-        );
-
-        Ok(canonical_result)
+        })
     }
 
     /// Given the (canonicalized) result to a canonical query,