pub struct SolverRelating<'infcx, Infcx, I: Interner> {
infcx: &'infcx Infcx,
structurally_relate_aliases: StructurallyRelateAliases,
param_env: I::ParamEnv,
span: I::Span,
ambient_variance: Variance,
goals: Vec<Goal<I, I::Predicate>>,
cache: DelayedSet<(Variance, I::Ty, I::Ty)>,
}Expand description
Enforce that a is equal to or a subtype of b.
Fields§
§infcx: &'infcx Infcx§structurally_relate_aliases: StructurallyRelateAliases§param_env: I::ParamEnv§span: I::Span§ambient_variance: Variance§goals: Vec<Goal<I, I::Predicate>>§cache: DelayedSet<(Variance, I::Ty, I::Ty)>The cache only tracks the ambient_variance as it’s the
only field which is mutable and which meaningfully changes
the result when relating types.
The cache does not track whether the state of the
Infcx has been changed or whether we’ve added any
goals to self.goals. Whether a goal is added once or multiple
times is not really meaningful.
Changes in the inference state may delay some type inference to the next fulfillment loop. Given that this loop is already necessary, this is also not a meaningful change. Consider the following three relations:
Vec<?0> sub Vec<?1>
?0 eq u32
Vec<?0> sub Vec<?1>Without a cache, the second Vec<?0> sub Vec<?1> would eagerly
constrain ?1 to u32. When using the cache entry from the
first time we’ve related these types, this only happens when
later proving the Subtype(?0, ?1) goal from the first relation.
Implementations§
Source§impl<'infcx, Infcx, I> SolverRelating<'infcx, Infcx, I>where
Infcx: InferCtxtLike<Interner = I>,
I: Interner,
impl<'infcx, Infcx, I> SolverRelating<'infcx, Infcx, I>where
Infcx: InferCtxtLike<Interner = I>,
I: Interner,
pub fn new( infcx: &'infcx Infcx, structurally_relate_aliases: StructurallyRelateAliases, ambient_variance: Variance, param_env: I::ParamEnv, span: I::Span, ) -> Self
Trait Implementations§
Source§impl<Infcx, I> PredicateEmittingRelation<Infcx> for SolverRelating<'_, Infcx, I>where
Infcx: InferCtxtLike<Interner = I>,
I: Interner,
impl<Infcx, I> PredicateEmittingRelation<Infcx> for SolverRelating<'_, Infcx, I>where
Infcx: InferCtxtLike<Interner = I>,
I: Interner,
fn span(&self) -> I::Span
fn param_env(&self) -> I::ParamEnv
Source§fn structurally_relate_aliases(&self) -> StructurallyRelateAliases
fn structurally_relate_aliases(&self) -> StructurallyRelateAliases
No unless you’re equating in some specific locations of the
new solver. See the comments in these use-cases for more details.Source§fn register_predicates(
&mut self,
obligations: impl IntoIterator<Item: Upcast<I, I::Predicate>>,
)
fn register_predicates( &mut self, obligations: impl IntoIterator<Item: Upcast<I, I::Predicate>>, )
param_env of the obligation.Source§fn register_goals(
&mut self,
obligations: impl IntoIterator<Item = Goal<I, I::Predicate>>,
)
fn register_goals( &mut self, obligations: impl IntoIterator<Item = Goal<I, I::Predicate>>, )
Source§fn register_alias_relate_predicate(&mut self, a: I::Ty, b: I::Ty)
fn register_alias_relate_predicate(&mut self, a: I::Ty, b: I::Ty)
AliasRelate obligation(s) that both types must be related to each other.Source§impl<Infcx, I> TypeRelation<I> for SolverRelating<'_, Infcx, I>where
Infcx: InferCtxtLike<Interner = I>,
I: Interner,
impl<Infcx, I> TypeRelation<I> for SolverRelating<'_, Infcx, I>where
Infcx: InferCtxtLike<Interner = I>,
I: Interner,
fn cx(&self) -> I
Source§fn relate_item_args(
&mut self,
item_def_id: I::DefId,
a_arg: I::GenericArgs,
b_arg: I::GenericArgs,
) -> RelateResult<I, I::GenericArgs>
fn relate_item_args( &mut self, item_def_id: I::DefId, a_arg: I::GenericArgs, b_arg: I::GenericArgs, ) -> RelateResult<I, I::GenericArgs>
Source§fn relate_with_variance<T: Relate<I>>(
&mut self,
variance: Variance,
_info: VarianceDiagInfo<I>,
a: T,
b: T,
) -> RelateResult<I, T>
fn relate_with_variance<T: Relate<I>>( &mut self, variance: Variance, _info: VarianceDiagInfo<I>, a: T, b: T, ) -> RelateResult<I, T>
a and b.fn tys(&mut self, a: I::Ty, b: I::Ty) -> RelateResult<I, I::Ty>
fn regions(&mut self, a: I::Region, b: I::Region) -> RelateResult<I, I::Region>
fn consts(&mut self, a: I::Const, b: I::Const) -> RelateResult<I, I::Const>
fn binders<T>(
&mut self,
a: Binder<I, T>,
b: Binder<I, T>,
) -> RelateResult<I, Binder<I, T>>where
T: Relate<I>,
Source§fn relate<T: Relate<I>>(&mut self, a: T, b: T) -> RelateResult<I, T>
fn relate<T: Relate<I>>(&mut self, a: T, b: T) -> RelateResult<I, T>
Auto Trait Implementations§
impl<'infcx, Infcx, I> DynSend for SolverRelating<'infcx, Infcx, I>
impl<'infcx, Infcx, I> DynSync for SolverRelating<'infcx, Infcx, I>
impl<'infcx, Infcx, I> Freeze for SolverRelating<'infcx, Infcx, I>
impl<'infcx, Infcx, I> RefUnwindSafe for SolverRelating<'infcx, Infcx, I>where
<I as Interner>::ParamEnv: RefUnwindSafe,
<I as Interner>::Span: RefUnwindSafe,
Infcx: RefUnwindSafe,
<I as Interner>::Predicate: RefUnwindSafe,
<I as Interner>::Ty: RefUnwindSafe,
impl<'infcx, Infcx, I> Send for SolverRelating<'infcx, Infcx, I>
impl<'infcx, Infcx, I> Sync for SolverRelating<'infcx, Infcx, I>
impl<'infcx, Infcx, I> Unpin for SolverRelating<'infcx, Infcx, I>
impl<'infcx, Infcx, I> UnwindSafe for SolverRelating<'infcx, Infcx, I>where
<I as Interner>::ParamEnv: UnwindSafe,
<I as Interner>::Span: UnwindSafe,
Infcx: RefUnwindSafe,
<I as Interner>::Predicate: UnwindSafe,
<I as Interner>::Ty: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T, R> CollectAndApply<T, R> for T
impl<T, R> CollectAndApply<T, R> for T
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
impl<I, T, U> Upcast<I, U> for Twhere
U: UpcastFrom<I, T>,
Source§impl<I, T> UpcastFrom<I, T> for T
impl<I, T> UpcastFrom<I, T> for T
fn upcast_from(from: T, _tcx: I) -> T
Source§impl<T> WithSubscriber for T
impl<T> WithSubscriber for T
Source§fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
Source§fn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
impl<T> ErasedDestructor for Twhere
T: 'static,
Layout§
Note: Unable to compute type layout, possibly due to this type having generic parameters. Layout can only be computed for concrete, fully-instantiated types.