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>

source

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.

source

pub fn is_trivial_and_always_true(&self, interner: I) -> bool

source

pub fn into_guidance(self) -> Guidance<I>

View this solution purely in terms of type inference guidance

source

pub fn constrained_subst( &self, interner: I, ) -> Option<Canonical<ConstrainedSubst<I>>>

Extract a constrained substitution from this solution, even if ambiguous.

source

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.

source

pub fn is_unique(&self) -> bool

source

pub fn is_ambig(&self) -> bool

source

pub fn display(&self, interner: I) -> SolutionDisplay<'_, I>

Trait Implementations§

source§

impl<I: Clone + Interner> Clone for Solution<I>

source§

fn clone(&self) -> Solution<I>

Returns a copy of the value. Read more
1.0.0 · source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
source§

impl<I: Debug + Interner> Debug for Solution<I>

source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
source§

impl<I: Interner> HasInterner for Solution<I>

§

type Interner = I

The interner associated with the type.
source§

impl<I: PartialEq + Interner> PartialEq for Solution<I>

source§

fn eq(&self, other: &Solution<I>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<I: Eq + Interner> Eq for Solution<I>

source§

impl<I: Interner> StructuralPartialEq for Solution<I>

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> Cast for T

source§

fn cast<U>(self, interner: <U as HasInterner>::Interner) -> U
where Self: CastTo<U>, U: HasInterner,

Cast a value to type U using CastTo.
source§

impl<T> CloneToUninit for T
where T: Clone,

source§

default unsafe fn clone_to_uninit(&self, dst: *mut T)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

§

fn equivalent(&self, key: &K) -> bool

Compare self to key and return true if they are equal.
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> ToOwned for T
where T: Clone,

§

type Owned = T

The resulting type after obtaining ownership.
source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more