1
Fork 0

Uplift Goal to rustc_type_ir

This commit is contained in:
Michael Goulet 2024-05-15 21:57:41 -04:00
parent 2684655602
commit 138881b315
22 changed files with 130 additions and 109 deletions

View file

@ -339,7 +339,7 @@ impl<'infcx, 'tcx> CombineFields<'infcx, 'tcx> {
pub fn register_predicates(
&mut self,
obligations: impl IntoIterator<Item: Upcast<'tcx, ty::Predicate<'tcx>>>,
obligations: impl IntoIterator<Item: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
) {
self.obligations.extend(obligations.into_iter().map(|to_pred| {
Obligation::new(self.infcx.tcx, self.trace.cause.clone(), self.param_env, to_pred)
@ -365,7 +365,7 @@ pub trait ObligationEmittingRelation<'tcx>: TypeRelation<'tcx> {
/// be used if control over the obligation causes is required.
fn register_predicates(
&mut self,
obligations: impl IntoIterator<Item: Upcast<'tcx, ty::Predicate<'tcx>>>,
obligations: impl IntoIterator<Item: Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
);
/// Register `AliasRelate` obligation(s) that both types must be related to each other.

View file

@ -142,7 +142,7 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Glb<'_, '_, 'tcx> {
fn register_predicates(
&mut self,
obligations: impl IntoIterator<Item: ty::Upcast<'tcx, ty::Predicate<'tcx>>>,
obligations: impl IntoIterator<Item: ty::Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
) {
self.fields.register_predicates(obligations);
}

View file

@ -142,7 +142,7 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for Lub<'_, '_, 'tcx> {
fn register_predicates(
&mut self,
obligations: impl IntoIterator<Item: ty::Upcast<'tcx, ty::Predicate<'tcx>>>,
obligations: impl IntoIterator<Item: ty::Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
) {
self.fields.register_predicates(obligations);
}

View file

@ -314,7 +314,7 @@ impl<'tcx> ObligationEmittingRelation<'tcx> for TypeRelating<'_, '_, 'tcx> {
fn register_predicates(
&mut self,
obligations: impl IntoIterator<Item: ty::Upcast<'tcx, ty::Predicate<'tcx>>>,
obligations: impl IntoIterator<Item: ty::Upcast<TyCtxt<'tcx>, ty::Predicate<'tcx>>>,
) {
self.fields.register_predicates(obligations);
}

View file

@ -78,9 +78,9 @@ impl<T: Hash> Hash for Obligation<'_, T> {
}
}
impl<'tcx, P> From<Obligation<'tcx, P>> for solve::Goal<'tcx, P> {
impl<'tcx, P> From<Obligation<'tcx, P>> for ty::Goal<'tcx, P> {
fn from(value: Obligation<'tcx, P>) -> Self {
solve::Goal { param_env: value.param_env, predicate: value.predicate }
ty::Goal { param_env: value.param_env, predicate: value.predicate }
}
}
@ -155,7 +155,7 @@ impl<'tcx, O> Obligation<'tcx, O> {
tcx: TyCtxt<'tcx>,
cause: ObligationCause<'tcx>,
param_env: ty::ParamEnv<'tcx>,
predicate: impl Upcast<'tcx, O>,
predicate: impl Upcast<TyCtxt<'tcx>, O>,
) -> Obligation<'tcx, O> {
Self::with_depth(tcx, cause, 0, param_env, predicate)
}
@ -173,7 +173,7 @@ impl<'tcx, O> Obligation<'tcx, O> {
cause: ObligationCause<'tcx>,
recursion_depth: usize,
param_env: ty::ParamEnv<'tcx>,
predicate: impl Upcast<'tcx, O>,
predicate: impl Upcast<TyCtxt<'tcx>, O>,
) -> Obligation<'tcx, O> {
let predicate = predicate.upcast(tcx);
Obligation { cause, param_env, recursion_depth, predicate }
@ -184,12 +184,16 @@ impl<'tcx, O> Obligation<'tcx, O> {
span: Span,
body_id: LocalDefId,
param_env: ty::ParamEnv<'tcx>,
trait_ref: impl Upcast<'tcx, O>,
trait_ref: impl Upcast<TyCtxt<'tcx>, O>,
) -> Obligation<'tcx, O> {
Obligation::new(tcx, ObligationCause::misc(span, body_id), param_env, trait_ref)
}
pub fn with<P>(&self, tcx: TyCtxt<'tcx>, value: impl Upcast<'tcx, P>) -> Obligation<'tcx, P> {
pub fn with<P>(
&self,
tcx: TyCtxt<'tcx>,
value: impl Upcast<TyCtxt<'tcx>, P>,
) -> Obligation<'tcx, P> {
Obligation::with_depth(tcx, self.cause.clone(), self.recursion_depth, self.param_env, value)
}
}