|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 | 11 | use rustc::infer::canonical::{Canonical, QueryResult};
|
12 |
| -use rustc::traits::{self, FulfillmentContext, ObligationCause, SelectionContext}; |
13 |
| -use rustc::traits::query::{CanonicalProjectionGoal, NoSolution, normalize::NormalizationResult}; |
| 12 | +use rustc::infer::InferOk; |
| 13 | +use rustc::traits::query::{normalize::NormalizationResult, CanonicalProjectionGoal, NoSolution}; |
| 14 | +use rustc::traits::{self, ObligationCause, SelectionContext}; |
14 | 15 | use rustc::ty::{ParamEnvAnd, TyCtxt};
|
15 | 16 | use rustc_data_structures::sync::Lrc;
|
| 17 | +use std::sync::atomic::Ordering; |
16 | 18 | use syntax::ast::DUMMY_NODE_ID;
|
17 | 19 | use syntax_pos::DUMMY_SP;
|
18 |
| -use std::sync::atomic::Ordering; |
19 | 20 |
|
20 | 21 | crate fn normalize_projection_ty<'tcx>(
|
21 | 22 | tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
22 | 23 | goal: CanonicalProjectionGoal<'tcx>,
|
23 | 24 | ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, NormalizationResult<'tcx>>>>, NoSolution> {
|
24 | 25 | debug!("normalize_provider(goal={:#?})", goal);
|
25 | 26 |
|
26 |
| - tcx.sess.perf_stats.normalize_projection_ty.fetch_add(1, Ordering::Relaxed); |
27 |
| - tcx.infer_ctxt().enter(|ref infcx| { |
28 |
| - let ( |
29 |
| - ParamEnvAnd { |
| 27 | + tcx.sess |
| 28 | + .perf_stats |
| 29 | + .normalize_projection_ty |
| 30 | + .fetch_add(1, Ordering::Relaxed); |
| 31 | + tcx.infer_ctxt().enter_canonical_trait_query( |
| 32 | + &goal, |
| 33 | + |infcx, |
| 34 | + ParamEnvAnd { |
| 35 | + param_env, |
| 36 | + value: goal, |
| 37 | + }| { |
| 38 | + let selcx = &mut SelectionContext::new(infcx); |
| 39 | + let cause = ObligationCause::misc(DUMMY_SP, DUMMY_NODE_ID); |
| 40 | + let mut obligations = vec![]; |
| 41 | + let answer = traits::normalize_projection_type( |
| 42 | + selcx, |
30 | 43 | param_env,
|
31 |
| - value: goal, |
32 |
| - }, |
33 |
| - canonical_inference_vars, |
34 |
| - ) = infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &goal); |
35 |
| - let fulfill_cx = &mut FulfillmentContext::new(); |
36 |
| - let selcx = &mut SelectionContext::new(infcx); |
37 |
| - let cause = ObligationCause::misc(DUMMY_SP, DUMMY_NODE_ID); |
38 |
| - let mut obligations = vec![]; |
39 |
| - let answer = |
40 |
| - traits::normalize_projection_type(selcx, param_env, goal, cause, 0, &mut obligations); |
41 |
| - fulfill_cx.register_predicate_obligations(infcx, obligations); |
42 |
| - |
43 |
| - // Now that we have fulfilled as much as we can, create a solution |
44 |
| - // from what we've learned. |
45 |
| - infcx.make_canonicalized_query_result( |
46 |
| - canonical_inference_vars, |
47 |
| - NormalizationResult { normalized_ty: answer }, |
48 |
| - fulfill_cx, |
49 |
| - ) |
50 |
| - }) |
| 44 | + goal, |
| 45 | + cause, |
| 46 | + 0, |
| 47 | + &mut obligations, |
| 48 | + ); |
| 49 | + Ok(InferOk { |
| 50 | + value: NormalizationResult { |
| 51 | + normalized_ty: answer, |
| 52 | + }, |
| 53 | + obligations, |
| 54 | + }) |
| 55 | + }, |
| 56 | + ) |
51 | 57 | }
|
0 commit comments