Enum chalk_solve::solve::Solution
source · pub enum Solution<I: Interner> {
Unique(Canonical<ConstrainedSubst<I>>),
Ambig(Guidance<I>),
}
Expand description
A (possible) solution for a proposed goal.
Variants§
Unique(Canonical<ConstrainedSubst<I>>)
The goal indeed holds, and there is a unique value for all existential variables. In this case, we also record a set of lifetime constraints which must also hold for the goal to be valid.
Ambig(Guidance<I>)
The goal may be provable in multiple ways, but regardless we may have some guidance for type inference. In this case, we don’t return any lifetime constraints, since we have not “committed” to any particular solution yet.
Implementations§
source§impl<I: Interner> Solution<I>
impl<I: Interner> Solution<I>
sourcepub fn combine(self, other: Solution<I>, interner: I) -> Solution<I>
pub fn combine(self, other: Solution<I>, interner: I) -> Solution<I>
There are multiple candidate solutions, which may or may not agree on the values for existential variables; attempt to combine them. This operation does not depend on the order of its arguments.
This actually isn’t as precise as it could be, in two ways:
a. It might be that while there are multiple distinct candidates, they all agree about some things. To be maximally precise, we would compute the intersection of what they agree on. It’s not clear though that this is actually what we want Rust’s inference to do, and it’s certainly not what it does today.
b. There might also be an ambiguous candidate and a successful candidate,
both with the same refined-goal. In that case, we could probably claim
success, since if the conditions of the ambiguous candidate were met,
we know the success would apply. Example: ?0: Clone
yields ambiguous
candidate Option<?0>: Clone
and successful candidate Option<?0>: Clone
.
But you get the idea.
pub fn is_trivial_and_always_true(&self, interner: I) -> bool
sourcepub fn into_guidance(self) -> Guidance<I>
pub fn into_guidance(self) -> Guidance<I>
View this solution purely in terms of type inference guidance
sourcepub fn constrained_subst(
&self,
interner: I,
) -> Option<Canonical<ConstrainedSubst<I>>>
pub fn constrained_subst( &self, interner: I, ) -> Option<Canonical<ConstrainedSubst<I>>>
Extract a constrained substitution from this solution, even if ambiguous.
sourcepub fn definite_subst(
&self,
interner: I,
) -> Option<Canonical<ConstrainedSubst<I>>>
pub fn definite_subst( &self, interner: I, ) -> Option<Canonical<ConstrainedSubst<I>>>
Determine whether this solution contains type information that must hold, and returns the subst in that case.
pub fn is_unique(&self) -> bool
pub fn is_ambig(&self) -> bool
pub fn display(&self, interner: I) -> SolutionDisplay<'_, I>
Trait Implementations§
source§impl<I: Interner> HasInterner for Solution<I>
impl<I: Interner> HasInterner for Solution<I>
source§impl<I: PartialEq + Interner> PartialEq for Solution<I>
impl<I: PartialEq + Interner> PartialEq for Solution<I>
impl<I: Eq + Interner> Eq for Solution<I>
impl<I: Interner> StructuralPartialEq for Solution<I>
Auto Trait Implementations§
impl<I> Freeze for Solution<I>where
<I as Interner>::InternedCanonicalVarKinds: Freeze,
<I as Interner>::InternedSubstitution: Freeze,
<I as Interner>::InternedConstraints: Freeze,
impl<I> RefUnwindSafe for Solution<I>where
<I as Interner>::InternedCanonicalVarKinds: RefUnwindSafe,
<I as Interner>::InternedSubstitution: RefUnwindSafe,
<I as Interner>::InternedConstraints: RefUnwindSafe,
impl<I> Send for Solution<I>where
<I as Interner>::InternedCanonicalVarKinds: Send,
<I as Interner>::InternedSubstitution: Send,
<I as Interner>::InternedConstraints: Send,
impl<I> Sync for Solution<I>where
<I as Interner>::InternedCanonicalVarKinds: Sync,
<I as Interner>::InternedSubstitution: Sync,
<I as Interner>::InternedConstraints: Sync,
impl<I> Unpin for Solution<I>where
<I as Interner>::InternedCanonicalVarKinds: Unpin,
<I as Interner>::InternedSubstitution: Unpin,
<I as Interner>::InternedConstraints: Unpin,
impl<I> UnwindSafe for Solution<I>where
<I as Interner>::InternedCanonicalVarKinds: UnwindSafe,
<I as Interner>::InternedSubstitution: UnwindSafe,
<I as Interner>::InternedConstraints: 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> Cast for T
impl<T> Cast for T
source§fn cast<U>(self, interner: <U as HasInterner>::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> Uwhere
Self: CastTo<U>,
U: HasInterner,
U
using CastTo
.source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§default unsafe fn clone_to_uninit(&self, dst: *mut T)
default unsafe fn clone_to_uninit(&self, dst: *mut T)
clone_to_uninit
)§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key
and return true
if they are equal.