|
9 | 9 | // except according to those terms.
|
10 | 10 |
|
11 | 11 | use rustc::infer::canonical::{Canonical, QueryResult};
|
12 |
| -use rustc::infer::InferCtxt; |
| 12 | +use rustc::infer::{InferCtxt, InferOk}; |
13 | 13 | use rustc::traits::query::type_op::normalize::Normalize;
|
14 |
| -use rustc::traits::query::NoSolution; |
15 |
| -use rustc::traits::{FulfillmentContext, Normalized, ObligationCause}; |
| 14 | +use rustc::traits::query::{Fallible, NoSolution}; |
| 15 | +use rustc::traits::{Normalized, ObligationCause}; |
16 | 16 | use rustc::ty::{FnSig, Lift, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable};
|
17 | 17 | use rustc_data_structures::sync::Lrc;
|
18 | 18 | use std::fmt;
|
19 |
| -use syntax::codemap::DUMMY_SP; |
20 | 19 |
|
21 |
| -fn type_op_normalize<'gcx, 'tcx, T>( |
| 20 | +fn type_op_normalize<T>( |
22 | 21 | infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
23 |
| - canonicalized: Canonical<'tcx, Normalize<'tcx, T>>, |
24 |
| -) -> Result<Lrc<Canonical<'gcx, QueryResult<'gcx, <T as Lift<'gcx>>::Lifted>>>, NoSolution> |
| 22 | + key: Normalize<'tcx, T>, |
| 23 | +) -> Fallible<InferOk<'tcx, T>> |
25 | 24 | where
|
26 | 25 | T: fmt::Debug + TypeFoldable<'tcx> + Lift<'gcx>,
|
27 | 26 | {
|
28 |
| - let (Normalize { param_env, value }, canonical_inference_vars) = |
29 |
| - infcx.instantiate_canonical_with_fresh_inference_vars(DUMMY_SP, &canonicalized); |
30 |
| - let fulfill_cx = &mut FulfillmentContext::new(); |
| 27 | + let Normalize { param_env, value } = key; |
31 | 28 | let Normalized { value, obligations } = infcx
|
32 | 29 | .at(&ObligationCause::dummy(), param_env)
|
33 | 30 | .normalize(&value)?;
|
34 |
| - fulfill_cx.register_predicate_obligations(infcx, obligations); |
35 |
| - infcx.make_canonicalized_query_result(canonical_inference_vars, value, fulfill_cx) |
| 31 | + Ok(InferOk { value, obligations }) // ugh we should merge these two structs |
36 | 32 | }
|
37 | 33 |
|
38 |
| -crate fn type_op_normalize_ty<'tcx>( |
| 34 | +crate fn type_op_normalize_ty( |
39 | 35 | tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
40 | 36 | canonicalized: Canonical<'tcx, Normalize<'tcx, Ty<'tcx>>>,
|
41 | 37 | ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Ty<'tcx>>>>, NoSolution> {
|
42 | 38 | tcx.infer_ctxt()
|
43 |
| - .enter(|ref infcx| type_op_normalize(infcx, canonicalized)) |
| 39 | + .enter_canonical_trait_query(&canonicalized, type_op_normalize) |
44 | 40 | }
|
45 | 41 |
|
46 |
| -crate fn type_op_normalize_predicate<'tcx>( |
| 42 | +crate fn type_op_normalize_predicate( |
47 | 43 | tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
48 | 44 | canonicalized: Canonical<'tcx, Normalize<'tcx, Predicate<'tcx>>>,
|
49 | 45 | ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, Predicate<'tcx>>>>, NoSolution> {
|
50 | 46 | tcx.infer_ctxt()
|
51 |
| - .enter(|ref infcx| type_op_normalize(infcx, canonicalized)) |
| 47 | + .enter_canonical_trait_query(&canonicalized, type_op_normalize) |
52 | 48 | }
|
53 | 49 |
|
54 |
| -crate fn type_op_normalize_fn_sig<'tcx>( |
| 50 | +crate fn type_op_normalize_fn_sig( |
55 | 51 | tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
56 | 52 | canonicalized: Canonical<'tcx, Normalize<'tcx, FnSig<'tcx>>>,
|
57 | 53 | ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, FnSig<'tcx>>>>, NoSolution> {
|
58 | 54 | tcx.infer_ctxt()
|
59 |
| - .enter(|ref infcx| type_op_normalize(infcx, canonicalized)) |
| 55 | + .enter_canonical_trait_query(&canonicalized, type_op_normalize) |
60 | 56 | }
|
61 | 57 |
|
62 |
| -crate fn type_op_normalize_poly_fn_sig<'tcx>( |
| 58 | +crate fn type_op_normalize_poly_fn_sig( |
63 | 59 | tcx: TyCtxt<'_, 'tcx, 'tcx>,
|
64 | 60 | canonicalized: Canonical<'tcx, Normalize<'tcx, PolyFnSig<'tcx>>>,
|
65 | 61 | ) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, PolyFnSig<'tcx>>>>, NoSolution> {
|
66 | 62 | tcx.infer_ctxt()
|
67 |
| - .enter(|ref infcx| type_op_normalize(infcx, canonicalized)) |
| 63 | + .enter_canonical_trait_query(&canonicalized, type_op_normalize) |
68 | 64 | }
|
0 commit comments