-
Notifications
You must be signed in to change notification settings - Fork 180
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Don't return definite guidance if we find one solution and then flounder #331
Conversation
This adds some tools helpful when debugging nondeterminism in analysis-stats: - a `--randomize` option that analyses everything in random order - a `-vv` option that prints even more detail Also add a debug log if Chalk fuel is exhausted (which would be a source of nondeterminism, but didn't happen in my tests). I found one source of nondeterminism (rust-lang/chalk#331), but there are still other cases remaining.
This adds some tools helpful when debugging nondeterminism in analysis-stats: - a `--randomize` option that analyses everything in random order - a `-vv` option that prints even more detail Also add a debug log if Chalk fuel is exhausted (which would be a source of nondeterminism, but didn't happen in my tests). I found one source of nondeterminism (rust-lang/chalk#331), but there are still other cases remaining.
I think there may still be a problem with the |
3157: Extend analysis-stats a bit r=matklad a=flodiebold This adds some tools helpful when debugging nondeterminism in analysis-stats: - a `--randomize` option that analyses everything in random order - a `-vv` option that prints even more detail Also add a debug log if Chalk fuel is exhausted (which would be a source of nondeterminism, but didn't happen in my tests). I found one source of nondeterminism (rust-lang/chalk#331), but there are still other cases remaining. Co-authored-by: Florian Diebold <flodiebold@gmail.com>
I have to think about this a bit more, but I don't think this fix is the most correct one to make.
This might be a problem with Nevertheless, thanks for the test. If you remove |
def4cf4
to
f1ce23a
Compare
That's very possible, especially since there still seems to be some similar problem.
Yes.
Done. |
Ok, I was able to reproduce the second problem: /// Don't return definite guidance if we are able to merge two solutions and the
/// third one matches that as well (the fourth may not).
#[test]
fn normalize_ambiguous() {
test! {
program {
trait IntoIterator { type Item; }
struct Ref<T> { }
struct A { }
struct B { }
struct C { }
struct D { }
impl IntoIterator for Ref<A> { type Item = Ref<A>; }
impl IntoIterator for Ref<B> { type Item = Ref<B>; }
impl IntoIterator for Ref<C> { type Item = Ref<C>; }
impl IntoIterator for Ref<D> { type Item = D; }
}
goal {
exists<T, U> {
Normalize(<Ref<T> as IntoIterator>::Item -> U)
}
} yields {
"Ambiguous; no inference guidance"
}
}
} This currently results in
because |
|
Also, this test (in the comment) passes on current |
Ah, I think with my change it hits the 'answer cached' case: chalk/chalk-engine/src/logic.rs Lines 213 to 216 in f85bb2e
|
@@ -69,6 +69,10 @@ impl<I: Interner> context::AggregateOps<SlgContext<I>> for SlgContextOps<'_, I> | |||
break Guidance::Unknown; | |||
} | |||
|
|||
if let AnswerResult::Floundered = answers.peek_answer(|| should_continue()) { | |||
break Guidance::Suggested(subst); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hmm, I think if we floundered we probably want Guidance::Unknown
, as that suggests that we never really explored the options.
But I see there were a lot more comments :) I have to read those and fully grok what they're saying |
This adds some tools helpful when debugging nondeterminism in analysis-stats: - a `--randomize` option that analyses everything in random order - a `-vv` option that prints even more detail Also add a debug log if Chalk fuel is exhausted (which would be a source of nondeterminism, but didn't happen in my tests). I found one source of nondeterminism (rust-lang/chalk#331), but there are still other cases remaining.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@flodiebold would you be up to rebase this, but return Guidance::Unknown
in the case of floundering?
If we find one solution and then flounder, this previously resulted in a `Guidance::Definite` result. I think the reason is that `any_future_answer` has no answers to check and hence returns true.
f1ce23a
to
9d655f4
Compare
@nikomatsakis Done! I added the second test as well, with the currently wrong result. |
/// Don't return definite guidance if we are able to merge two solutions and the | ||
/// third one matches that as well (the fourth may not). | ||
#[test] | ||
fn normalize_ambiguous() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does this test have anything to do with floundering?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think so (except that this test only reproduces the problem with the fix for the other problem, I think because it calls peek_answer
)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I see, curious.
Normalize(<Ref<T> as IntoIterator>::Item -> U) | ||
} | ||
} yields { | ||
// FIXME: this is wrong! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We should probably create a FIXME policy of creating open issues to track these...
I'm confused I guess if we want to land this now and investigate later or do more investigation. It seems like it's improving some problems you encountered in rust-analyzer? |
I think we could land this now. It's not that important for rust-analyzer anymore though since I switched to the recursive solver ;) |
If we find one solution and then flounder, this previously resulted in a
Guidance::Definite
result. I think the reason is thatany_future_answer
has no answers to check and hence returns true.