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
sourceimpl<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
sourceimpl<I: Interner> HasInterner for Solution<I>
impl<I: Interner> HasInterner for Solution<I>
type Interner = I
type Interner = I
The interner associated with the type.
impl<I: Eq + Interner> Eq for Solution<I>
impl<I: Interner> StructuralEq for Solution<I>
impl<I: Interner> StructuralPartialEq for Solution<I>
Auto Trait Implementations
impl<I> RefUnwindSafe for Solution<I> where
<I as Interner>::InternedCanonicalVarKinds: RefUnwindSafe,
<I as Interner>::InternedConstraints: RefUnwindSafe,
<I as Interner>::InternedSubstitution: RefUnwindSafe,
impl<I> Send for Solution<I> where
<I as Interner>::InternedCanonicalVarKinds: Send,
<I as Interner>::InternedConstraints: Send,
<I as Interner>::InternedSubstitution: Send,
impl<I> Sync for Solution<I> where
<I as Interner>::InternedCanonicalVarKinds: Sync,
<I as Interner>::InternedConstraints: Sync,
<I as Interner>::InternedSubstitution: Sync,
impl<I> Unpin for Solution<I> where
<I as Interner>::InternedCanonicalVarKinds: Unpin,
<I as Interner>::InternedConstraints: Unpin,
<I as Interner>::InternedSubstitution: Unpin,
impl<I> UnwindSafe for Solution<I> where
<I as Interner>::InternedCanonicalVarKinds: UnwindSafe,
<I as Interner>::InternedConstraints: UnwindSafe,
<I as Interner>::InternedSubstitution: UnwindSafe,
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> Cast for T
impl<T> Cast for T
sourcefn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U where
Self: CastTo<U>,
U: HasInterner,
Cast a value to type U
using CastTo
.
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more