|
1 | 1 | pubuse rustc_type_ir::relate::*; |
2 | | -use rustc_type_ir::solve::Goal; |
| 2 | +use rustc_type_ir::solve::{Goal,NoSolution}; |
3 | 3 | use rustc_type_ir::{selfas ty,InferCtxtLike,Interner}; |
4 | 4 | use tracing::{debug, instrument}; |
5 | 5 |
|
6 | 6 | useself::combine::{InferCtxtCombineExt,PredicateEmittingRelation}; |
7 | 7 | usecrate::data_structures::DelayedSet; |
8 | 8 |
|
9 | | -#[allow(unused)] |
| 9 | +pubtraitRelateExt:InferCtxtLike{ |
| 10 | +fnrelate<T:Relate<Self::Interner>>( |
| 11 | +&self, |
| 12 | +param_env: <Self::InternerasInterner>::ParamEnv, |
| 13 | +lhs:T, |
| 14 | +variance: ty::Variance, |
| 15 | +rhs:T, |
| 16 | +) -> Result<Vec<Goal<Self::Interner, <Self::InternerasInterner>::Predicate>>,NoSolution>; |
| 17 | + |
| 18 | +fneq_structurally_relating_aliases<T:Relate<Self::Interner>>( |
| 19 | +&self, |
| 20 | +param_env: <Self::InternerasInterner>::ParamEnv, |
| 21 | +lhs:T, |
| 22 | +rhs:T, |
| 23 | +) -> Result<Vec<Goal<Self::Interner, <Self::InternerasInterner>::Predicate>>,NoSolution>; |
| 24 | +} |
| 25 | + |
| 26 | +impl<Infcx:InferCtxtLike>RelateExtforInfcx{ |
| 27 | +fnrelate<T:Relate<Self::Interner>>( |
| 28 | +&self, |
| 29 | +param_env: <Self::InternerasInterner>::ParamEnv, |
| 30 | +lhs:T, |
| 31 | +variance: ty::Variance, |
| 32 | +rhs:T, |
| 33 | +) -> Result<Vec<Goal<Self::Interner, <Self::InternerasInterner>::Predicate>>,NoSolution> |
| 34 | +{ |
| 35 | +letmut relate = |
| 36 | +SolverRelating::new(self,StructurallyRelateAliases::No, variance, param_env); |
| 37 | + relate.relate(lhs, rhs)?; |
| 38 | +Ok(relate.goals) |
| 39 | +} |
| 40 | + |
| 41 | +fneq_structurally_relating_aliases<T:Relate<Self::Interner>>( |
| 42 | +&self, |
| 43 | +param_env: <Self::InternerasInterner>::ParamEnv, |
| 44 | +lhs:T, |
| 45 | +rhs:T, |
| 46 | +) -> Result<Vec<Goal<Self::Interner, <Self::InternerasInterner>::Predicate>>,NoSolution> |
| 47 | +{ |
| 48 | +letmut relate = |
| 49 | +SolverRelating::new(self,StructurallyRelateAliases::Yes, ty::Invariant, param_env); |
| 50 | + relate.relate(lhs, rhs)?; |
| 51 | +Ok(relate.goals) |
| 52 | +} |
| 53 | +} |
| 54 | + |
10 | 55 | /// Enforce that `a` is equal to or a subtype of `b`. |
11 | 56 | pubstructSolverRelating<'infcx,Infcx,I:Interner>{ |
12 | 57 | infcx:&'infcxInfcx, |
|
46 | 91 | Infcx:InferCtxtLike<Interner = I>, |
47 | 92 | I:Interner, |
48 | 93 | { |
| 94 | +fnnew( |
| 95 | +infcx:&'infcxInfcx, |
| 96 | +structurally_relate_aliases:StructurallyRelateAliases, |
| 97 | +ambient_variance: ty::Variance, |
| 98 | +param_env:I::ParamEnv, |
| 99 | +) -> Self{ |
| 100 | +SolverRelating{ |
| 101 | + infcx, |
| 102 | + structurally_relate_aliases, |
| 103 | + ambient_variance, |
| 104 | + param_env, |
| 105 | +goals:vec![], |
| 106 | +cache:Default::default(), |
| 107 | +} |
| 108 | +} |
49 | 109 | } |
50 | 110 |
|
51 | 111 | impl<Infcx,I>TypeRelation<I>forSolverRelating<'_,Infcx,I> |
|
0 commit comments