about summary refs log tree commit diff
path: root/src
diff options
context:
space:
mode:
authorNiko Matsakis <niko@alum.mit.edu>2018-06-27 06:48:52 -0400
committerNiko Matsakis <niko@alum.mit.edu>2018-06-27 06:48:52 -0400
commitac40d73c6ff360fa260f842bf66c848c0ec81eec (patch)
treecbba0466659d30e46bfe68a60227950b72f2e477 /src
parentfa71af419207fbd0169f1e2d36abcfaf3bc4fab2 (diff)
downloadrust-ac40d73c6ff360fa260f842bf66c848c0ec81eec.tar.gz
rust-ac40d73c6ff360fa260f842bf66c848c0ec81eec.zip
use query boilerplate for subtype
Diffstat (limited to 'src')
-rw-r--r--src/librustc_traits/type_op_subtype.rs28
1 files changed, 14 insertions, 14 deletions
diff --git a/src/librustc_traits/type_op_subtype.rs b/src/librustc_traits/type_op_subtype.rs
index 1fa5ec915f2..30a8550f107 100644
--- a/src/librustc_traits/type_op_subtype.rs
+++ b/src/librustc_traits/type_op_subtype.rs
@@ -11,25 +11,25 @@
 use rustc::infer::canonical::{Canonical, QueryResult};
 use rustc::traits::query::type_op::subtype::Subtype;
 use rustc::traits::query::NoSolution;
-use rustc::traits::{FulfillmentContext, ObligationCause};
+use rustc::traits::ObligationCause;
 use rustc::ty::TyCtxt;
 use rustc_data_structures::sync::Lrc;
-use syntax::codemap::DUMMY_SP;
 
 crate fn type_op_subtype<'tcx>(
     tcx: TyCtxt<'_, 'tcx, 'tcx>,
     canonicalized: Canonical<'tcx, Subtype<'tcx>>,
 ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
-    let tcx = tcx.global_tcx();
-    tcx.infer_ctxt().enter(|ref infcx| {
-        let (Subtype { param_env, sub, sup }, canonical_inference_vars) =
-            infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonicalized);
-        let fulfill_cx = &mut FulfillmentContext::new();
-        let obligations = match infcx.at(&ObligationCause::dummy(), param_env).sup(sup, sub) {
-            Ok(v) => v.into_obligations(),
-            Err(_) => return Err(NoSolution),
-        };
-        fulfill_cx.register_predicate_obligations(infcx, obligations);
-        infcx.make_canonicalized_query_result(canonical_inference_vars, (), fulfill_cx)
-    })
+    tcx.infer_ctxt().enter_canonical_trait_query(
+        &canonicalized,
+        |infcx,
+         Subtype {
+             param_env,
+             sub,
+             sup,
+         }| {
+            Ok(infcx
+                .at(&ObligationCause::dummy(), param_env)
+                .sup(sup, sub)?)
+        },
+    )
 }