-
Notifications
You must be signed in to change notification settings - Fork 1.7k
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
Unknown type in basic hyper
code
#14369
Comments
This was referenced Apr 22, 2023
bors
added a commit
to rust-lang/chalk
that referenced
this issue
Jun 14, 2023
…kh726 Generalize program clause for `AliasEq` goal with nested alias Consider a goal: `AliasEq(<<?0 as X>::A as Y>::B = <<?1 as X>::A as Y>::B)`. This is expected to (eventually) flounder when the traits are non-enumerable and the variables are yet to be known, but it's currently **disproven**: 1. the goal is canonicalized as follows: - `forall<T, U> AliasEq(<<T as X>::A as Y>::B = <<U as X>::A as Y>::B)` 1. we produce the following `ProgramClause` that could match: - `forall<T, U, ..> AliasEq(<<T as X>::A as Y>::B = <<U as X>::A as Y>::B) :- AliasEq(..), AliasEq(..)` 1. the consequence of the (instantiated) clause is unified with the goal, which produces a subgoal: - `AliasEq(<<?0 as X>::A as Y>::B = <<?1 as X>::A as Y>::B)` - this is because when we unify rhs of `AliasEq`, we see two `AliasTy`s that we cannot unify structurally, forcing us to produce the subgoal 1. boom, cycle emerged, goal disproven! The problem is that because we're reusing the original goal as the consequence of the program clause we expect them to unify structurally, however we cannot unify aliases structurally in general (e.g. `<?0 as X>::A = <?1 as X>::A` does not imply `?0 = ?1`). This PR solves it by placing a fresh variable in rhs of the consequence `AliasEq` instead of reusing the original term. This ensures that rhs of the original `AliasEq` goal is preserved via unification without producing subgoals even if it's an alias. See rust-lang/rust-analyzer#14369 for a real world case where this issue arises.
Indeed, this seems to work now ( |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
This is not really a rust-analyzer bug but a chalk bug, nevertheless filing this here to make it known and so we have an open issue to point to.
Below is a modified example from hyper tutorial. Note that some of the functions have been removed for hyper 1.0, so make sure to use hyper 0.14.x to reproduce.
cc #13450, #14264, #14322, #14324, I believe they are all caused by this issue.
rust-analyzer version: rust-analyzer version: 0.0.0 (b4d7ea0 2023-03-14)
rustc version: rustc 1.68.0 (2c8cc3432 2023-03-06)
relevant settings: none
The text was updated successfully, but these errors were encountered: