-
Notifications
You must be signed in to change notification settings - Fork 182
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
Better guidance for projections #429
Comments
I've started looking into this and I think I've found why the solver fails, though I may need some guidance on how to properly fix it. @rustbot claim The gist is that the recursive solver gets to to the point where it has to prove Snippet from debug output
I've modified |
Returning Also #433 might be related to this, I'm not sure. |
I was a little confused by why |
Reading the debug output, a solution is found but the ambiguous solution from
Edit: the following is probably irrelevant, as both the SLG solver and recursive solver get the same answer, but the recursive solver disregards the trivial solution because it has a lower priority. I will look into #443 to see if the ideas can be adapted for the recursive solver.
Lines 643 to 660 in c8135bb
|
This is why: #235
That's also correct, the low-priority solution isn't really helpful here either, it's just a placeholder for the associated type in case we find no other solution.
The PR also contains a fix for the recursive solver, it's just much smaller apparently 😉 |
So I took another look at the Type equality and unification logic to figure out what path the logic is expected to take in order to arrive at the
The documentation proposes an additional condition, Intuitively, we know Edit: if this is the cause, then this issue generalizes to both solvers and the fix should fix both. |
That's the documentation being outdated; the condition for the
I'm not sure what exactly you see as "entering the impl" here. We try to apply the |
I mean "entering the impl" as the for loop over all the impls of chalk/chalk-solve/src/clauses.rs Lines 328 to 341 in 01690cf
We are given that |
We don't know that; otherwise the result would be that the normalization is always valid, which it isn't. But yes, the reasoning here is basically "if this were true, then the substitution would be |
Ok, now I feel a little silly, but at least I understand the solver code a little better. #443 fixes this issue for the recursive solver (a simple 6-line change). However, it regresses the SLG solver to return Edit: The solution is slightly different. It has a |
Actually, I think that's the correct way to write what I meant 🙂
Hm, well, the previous answer from the SLG solver is wrong anyway, and the SLG solver has problems with projections anyway (#234), so this doesn't seem that worrying to me, but I also don't know enough about the SLG solver to know whether there's a problem in the PR. |
I think the following test, or something similar, should pass:
I.e. the recursive solver should be able to tell that there is only one impl that could possibly apply, so we know the
Item
type. This is derived from the following real-world case (from rust-lang/rust-analyzer#4072:which rustc manages to figure out. (This isn't related to integer type variables / fallback, it's just an easy way to get a type variable.)
The SLG solver gives
Ambiguous; definite substitution for<?U0> { [?0 := ^0.0, ?1 := (Iterator::Item)<Range<^0.0>>] }
, which is also not very helpful, but that's related to other problems, I think.I haven't really looked into why this doesn't work in the recursive solver or how to fix it; I think it may be that the solver just gives up too early when one subgoal flounders (in this case the
?0: Step
goal). It could be a good first issue for getting into the recursive solver. It may be more complicated though.This issue has been assigned to @Mcat12 via this comment.
The text was updated successfully, but these errors were encountered: