|
8 | 8 | // option. This file may not be copied, modified, or distributed
|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
| 11 | +use rustc::infer::InferOk; |
11 | 12 | use rustc::infer::canonical::{Canonical, QueryResult};
|
12 | 13 | use rustc::traits::query::type_op::prove_predicate::ProvePredicate;
|
13 | 14 | use rustc::traits::query::NoSolution;
|
14 |
| -use rustc::traits::{FulfillmentContext, Obligation, ObligationCause, TraitEngine}; |
| 15 | +use rustc::traits::{Obligation, ObligationCause}; |
15 | 16 | use rustc::ty::TyCtxt;
|
16 | 17 | use rustc_data_structures::sync::Lrc;
|
17 |
| -use syntax::codemap::DUMMY_SP; |
18 | 18 |
|
19 | 19 | crate fn type_op_prove_predicate<'tcx>(
|
20 | 20 | tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
21 | 21 | canonicalized: Canonical<'tcx, ProvePredicate<'tcx>>,
|
22 | 22 | ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
|
23 |
| - let tcx = tcx.global_tcx(); |
24 |
| - tcx.infer_ctxt().enter(|ref infcx| { |
25 |
| - let (ProvePredicate { param_env, predicate }, canonical_inference_vars) = |
26 |
| - infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonicalized); |
27 |
| - let fulfill_cx = &mut FulfillmentContext::new(); |
28 |
| - let obligation = Obligation::new(ObligationCause::dummy(), param_env, predicate); |
29 |
| - fulfill_cx.register_predicate_obligation(infcx, obligation); |
30 |
| - infcx.make_canonicalized_query_result(canonical_inference_vars, (), fulfill_cx) |
31 |
| - }) |
| 23 | + tcx.infer_ctxt() |
| 24 | + .enter_canonical_trait_query(&canonicalized, |_infcx, key| { |
| 25 | + let ProvePredicate { |
| 26 | + param_env, |
| 27 | + predicate, |
| 28 | + } = key; |
| 29 | + Ok(InferOk { |
| 30 | + value: (), |
| 31 | + obligations: vec![Obligation::new( |
| 32 | + ObligationCause::dummy(), |
| 33 | + param_env, |
| 34 | + predicate, |
| 35 | + )], |
| 36 | + }) |
| 37 | + }) |
32 | 38 | }
|
0 commit comments