about summary refs log tree commit diff
diff options
context:
space:
mode:
-rw-r--r--src/librustc_traits/type_op_normalize.rs36
1 files changed, 16 insertions, 20 deletions
diff --git a/src/librustc_traits/type_op_normalize.rs b/src/librustc_traits/type_op_normalize.rs
index edfe627b15a..78e8a0ff3e6 100644
--- a/src/librustc_traits/type_op_normalize.rs
+++ b/src/librustc_traits/type_op_normalize.rs
@@ -9,60 +9,56 @@
 // except according to those terms.
 
 use rustc::infer::canonical::{Canonical, QueryResult};
-use rustc::infer::InferCtxt;
+use rustc::infer::{InferCtxt, InferOk};
 use rustc::traits::query::type_op::normalize::Normalize;
-use rustc::traits::query::NoSolution;
-use rustc::traits::{FulfillmentContext, Normalized, ObligationCause};
+use rustc::traits::query::{Fallible, NoSolution};
+use rustc::traits::{Normalized, ObligationCause};
 use rustc::ty::{FnSig, Lift, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable};
 use rustc_data_structures::sync::Lrc;
 use std::fmt;
-use syntax::codemap::DUMMY_SP;
 
-fn type_op_normalize<'gcx, 'tcx, T>(
+fn type_op_normalize<T>(
     infcx: &InferCtxt<'_, 'gcx, 'tcx>,
-    canonicalized: Canonical<'tcx, Normalize<'tcx, T>>,
-) -> Result<Lrc<Canonical<'gcx, QueryResult<'gcx, <T as Lift<'gcx>>::Lifted>>>, NoSolution>
+    key: Normalize<'tcx, T>,
+) -> Fallible<InferOk<'tcx, T>>
 where
     T: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx>,
 {
-    let (Normalize { param_env, value }, canonical_inference_vars) =
-        infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonicalized);
-    let fulfill_cx = &mut FulfillmentContext::new();
+    let Normalize { param_env, value } = key;
     let Normalized { value, obligations } = infcx
         .at(&ObligationCause::dummy(), param_env)
         .normalize(&value)?;
-    fulfill_cx.register_predicate_obligations(infcx, obligations);
-    infcx.make_canonicalized_query_result(canonical_inference_vars, value, fulfill_cx)
+    Ok(InferOk { value, obligations }) // ugh we should merge these two structs
 }
 
-crate fn type_op_normalize_ty<'tcx>(
+crate fn type_op_normalize_ty(
     tcx: TyCtxt<'_, 'tcx, 'tcx>,
     canonicalized: Canonical<'tcx, Normalize<'tcx, Ty<'tcx>>>,
 ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Ty<'tcx>>>>, NoSolution> {
     tcx.infer_ctxt()
-        .enter(|ref infcx| type_op_normalize(infcx, canonicalized))
+        .enter_canonical_trait_query(&canonicalized, type_op_normalize)
 }
 
-crate fn type_op_normalize_predicate<'tcx>(
+crate fn type_op_normalize_predicate(
     tcx: TyCtxt<'_, 'tcx, 'tcx>,
     canonicalized: Canonical<'tcx, Normalize<'tcx, Predicate<'tcx>>>,
 ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Predicate<'tcx>>>>, NoSolution> {
     tcx.infer_ctxt()
-        .enter(|ref infcx| type_op_normalize(infcx, canonicalized))
+        .enter_canonical_trait_query(&canonicalized, type_op_normalize)
 }
 
-crate fn type_op_normalize_fn_sig<'tcx>(
+crate fn type_op_normalize_fn_sig(
     tcx: TyCtxt<'_, 'tcx, 'tcx>,
     canonicalized: Canonical<'tcx, Normalize<'tcx, FnSig<'tcx>>>,
 ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, FnSig<'tcx>>>>, NoSolution> {
     tcx.infer_ctxt()
-        .enter(|ref infcx| type_op_normalize(infcx, canonicalized))
+        .enter_canonical_trait_query(&canonicalized, type_op_normalize)
 }
 
-crate fn type_op_normalize_poly_fn_sig<'tcx>(
+crate fn type_op_normalize_poly_fn_sig(
     tcx: TyCtxt<'_, 'tcx, 'tcx>,
     canonicalized: Canonical<'tcx, Normalize<'tcx, PolyFnSig<'tcx>>>,
 ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, PolyFnSig<'tcx>>>>, NoSolution> {
     tcx.infer_ctxt()
-        .enter(|ref infcx| type_op_normalize(infcx, canonicalized))
+        .enter_canonical_trait_query(&canonicalized, type_op_normalize)
 }