|
11 | 11 | use rustc::infer::canonical::{Canonical, QueryResult};
|
12 | 12 | use rustc::traits::query::type_op::subtype::Subtype;
|
13 | 13 | use rustc::traits::query::NoSolution;
|
14 |
| -use rustc::traits::{FulfillmentContext, ObligationCause}; |
| 14 | +use rustc::traits::ObligationCause; |
15 | 15 | use rustc::ty::TyCtxt;
|
16 | 16 | use rustc_data_structures::sync::Lrc;
|
17 |
| -use syntax::codemap::DUMMY_SP; |
18 | 17 |
|
19 | 18 | crate fn type_op_subtype<'tcx>(
|
20 | 19 | tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
21 | 20 | canonicalized: Canonical<'tcx, Subtype<'tcx>>,
|
22 | 21 | ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> {
|
23 |
| - let tcx = tcx.global_tcx(); |
24 |
| - tcx.infer_ctxt().enter(|ref infcx| { |
25 |
| - let (Subtype { param_env, sub, sup }, canonical_inference_vars) = |
26 |
| - infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonicalized); |
27 |
| - let fulfill_cx = &mut FulfillmentContext::new(); |
28 |
| - let obligations = match infcx.at(&ObligationCause::dummy(), param_env).sup(sup, sub) { |
29 |
| - Ok(v) => v.into_obligations(), |
30 |
| - Err(_) => return Err(NoSolution), |
31 |
| - }; |
32 |
| - fulfill_cx.register_predicate_obligations(infcx, obligations); |
33 |
| - infcx.make_canonicalized_query_result(canonical_inference_vars, (), fulfill_cx) |
34 |
| - }) |
| 22 | + tcx.infer_ctxt().enter_canonical_trait_query( |
| 23 | + &canonicalized, |
| 24 | + |infcx, |
| 25 | + Subtype { |
| 26 | + param_env, |
| 27 | + sub, |
| 28 | + sup, |
| 29 | + }| { |
| 30 | + Ok(infcx |
| 31 | + .at(&ObligationCause::dummy(), param_env) |
| 32 | + .sup(sup, sub)?) |
| 33 | + }, |
| 34 | + ) |
35 | 35 | }
|
0 commit comments