|
10 | 10 |
|
11 | 11 | use rustc::infer::canonical::{Canonical, QueryResult};
|
12 | 12 | use rustc::infer::{InferCtxt, InferOk};
|
| 13 | +use rustc::traits::query::type_op::eq::Eq; |
13 | 14 | use rustc::traits::query::type_op::normalize::Normalize;
|
| 15 | +use rustc::traits::query::type_op::prove_predicate::ProvePredicate; |
| 16 | +use rustc::traits::query::type_op::subtype::Subtype; |
14 | 17 | use rustc::traits::query::{Fallible, NoSolution};
|
15 |
| -use rustc::traits::{Normalized, ObligationCause}; |
| 18 | +use rustc::traits::{Obligation, Normalized, ObligationCause}; |
16 | 19 | use rustc::ty::{FnSig, Lift, PolyFnSig, Predicate, Ty, TyCtxt, TypeFoldable};
|
17 | 20 | use rustc_data_structures::sync::Lrc;
|
18 | 21 | use std::fmt;
|
19 | 22 |
|
| 23 | +crate fn type_op_eq<'tcx>( |
| 24 | + tcx: TyCtxt<'_, 'tcx, 'tcx>, |
| 25 | + canonicalized: Canonical<'tcx, Eq<'tcx>>, |
| 26 | +) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> { |
| 27 | + tcx.infer_ctxt() |
| 28 | + .enter_canonical_trait_query(&canonicalized, |infcx, Eq { param_env, a, b }| { |
| 29 | + Ok(infcx.at(&ObligationCause::dummy(), param_env).eq(a, b)?) |
| 30 | + }) |
| 31 | +} |
| 32 | + |
20 | 33 | fn type_op_normalize<T>(
|
21 | 34 | infcx: &InferCtxt<'_, 'gcx, 'tcx>,
|
22 | 35 | key: Normalize<'tcx, T>,
|
@@ -62,3 +75,43 @@ crate fn type_op_normalize_poly_fn_sig(
|
62 | 75 | tcx.infer_ctxt()
|
63 | 76 | .enter_canonical_trait_query(&canonicalized, type_op_normalize)
|
64 | 77 | }
|
| 78 | + |
| 79 | +crate fn type_op_subtype<'tcx>( |
| 80 | + tcx: TyCtxt<'_, 'tcx, 'tcx>, |
| 81 | + canonicalized: Canonical<'tcx, Subtype<'tcx>>, |
| 82 | +) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> { |
| 83 | + tcx.infer_ctxt().enter_canonical_trait_query( |
| 84 | + &canonicalized, |
| 85 | + |infcx, |
| 86 | + Subtype { |
| 87 | + param_env, |
| 88 | + sub, |
| 89 | + sup, |
| 90 | + }| { |
| 91 | + Ok(infcx |
| 92 | + .at(&ObligationCause::dummy(), param_env) |
| 93 | + .sup(sup, sub)?) |
| 94 | + }, |
| 95 | + ) |
| 96 | +} |
| 97 | + |
| 98 | +crate fn type_op_prove_predicate<'tcx>( |
| 99 | + tcx: TyCtxt<'_, 'tcx, 'tcx>, |
| 100 | + canonicalized: Canonical<'tcx, ProvePredicate<'tcx>>, |
| 101 | +) -> Result<Lrc<Canonical<'tcx, QueryResult<'tcx, ()>>>, NoSolution> { |
| 102 | + tcx.infer_ctxt() |
| 103 | + .enter_canonical_trait_query(&canonicalized, |_infcx, key| { |
| 104 | + let ProvePredicate { |
| 105 | + param_env, |
| 106 | + predicate, |
| 107 | + } = key; |
| 108 | + Ok(InferOk { |
| 109 | + value: (), |
| 110 | + obligations: vec![Obligation::new( |
| 111 | + ObligationCause::dummy(), |
| 112 | + param_env, |
| 113 | + predicate, |
| 114 | + )], |
| 115 | + }) |
| 116 | + }) |
| 117 | +} |
0 commit comments