review + some small stuff
This commit is contained in:
parent
2186847f28
commit
3fab7f7c13
7 changed files with 52 additions and 14 deletions
|
@ -56,9 +56,19 @@ pub enum Certainty {
|
|||
impl Certainty {
|
||||
pub const AMBIGUOUS: Certainty = Certainty::Maybe(MaybeCause::Ambiguity);
|
||||
|
||||
/// When proving multiple goals using **AND**, e.g. nested obligations for an impl,
|
||||
/// use this function to unify the certainty of these goals
|
||||
pub fn unify_and(self, other: Certainty) -> Certainty {
|
||||
/// Use this function to merge the certainty of multiple nested subgoals.
|
||||
///
|
||||
/// Given an impl like `impl<T: Foo + Bar> Baz for T {}`, we have 2 nested
|
||||
/// subgoals whenever we use the impl as a candidate: `T: Foo` and `T: Bar`.
|
||||
/// If evaluating `T: Foo` results in ambiguity and `T: Bar` results in
|
||||
/// success, we merge these two responses. This results in ambiguity.
|
||||
///
|
||||
/// If we unify ambiguity with overflow, we return overflow. This doesn't matter
|
||||
/// inside of the solver as we distinguish ambiguity from overflow. It does
|
||||
/// however matter for diagnostics. If `T: Foo` resulted in overflow and `T: Bar`
|
||||
/// in ambiguity without changing the inference state, we still want to tell the
|
||||
/// user that `T: Baz` results in overflow.
|
||||
pub fn unify_with(self, other: Certainty) -> Certainty {
|
||||
match (self, other) {
|
||||
(Certainty::Yes, Certainty::Yes) => Certainty::Yes,
|
||||
(Certainty::Yes, Certainty::Maybe(_)) => other,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue