1
Fork 0

Obligation::as_goal

This commit is contained in:
Michael Goulet 2025-03-22 22:09:16 +00:00
parent aa8f0fd716
commit 575f129faa
7 changed files with 17 additions and 18 deletions

View file

@ -246,8 +246,7 @@ impl<'tcx> InferCtxt<'tcx> {
.eq(DefineOpaqueTypes::Yes, prev, hidden_ty)?
.obligations
.into_iter()
// FIXME: Shuttling between obligations and goals is awkward.
.map(Goal::from),
.map(|obligation| obligation.as_goal()),
);
}
}

View file

@ -54,6 +54,12 @@ pub struct Obligation<'tcx, T> {
pub recursion_depth: usize,
}
impl<'tcx, T: Copy> Obligation<'tcx, T> {
pub fn as_goal(&self) -> solve::Goal<'tcx, T> {
solve::Goal { param_env: self.param_env, predicate: self.predicate }
}
}
impl<'tcx, T: PartialEq> PartialEq<Obligation<'tcx, T>> for Obligation<'tcx, T> {
#[inline]
fn eq(&self, other: &Obligation<'tcx, T>) -> bool {
@ -75,12 +81,6 @@ impl<T: Hash> Hash for Obligation<'_, T> {
}
}
impl<'tcx, P> From<Obligation<'tcx, P>> for solve::Goal<'tcx, P> {
fn from(value: Obligation<'tcx, P>) -> Self {
solve::Goal { param_env: value.param_env, predicate: value.predicate }
}
}
pub type PredicateObligation<'tcx> = Obligation<'tcx, ty::Predicate<'tcx>>;
pub type TraitObligation<'tcx> = Obligation<'tcx, ty::TraitPredicate<'tcx>>;
pub type PolyTraitObligation<'tcx> = Obligation<'tcx, ty::PolyTraitPredicate<'tcx>>;