Skip to content
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

Generate clauses for placeholder associated types #795

Merged
merged 1 commit into from
Jun 14, 2023

Conversation

lowr
Copy link
Contributor

@lowr lowr commented Apr 30, 2023

Currently, we don't generate clauses for placeholder associated types (TyKind::AssociatedType) except for some FromEnvs. This leads to NoSolution for goals like (IntoIterator::IntoIter)<Opaque>: Iterator where Opaque = impl IntoIterator.

For every associated type in a trait definition

trait Foo {
    type Assoc<'a, T>: Bar<U = Ty> where WC;
}

chalk with this patch generates

forall<Self, 'a, T> {
    Implemented((Foo::Assoc<'a, T>)<Self>: Bar) :- WC.
    AliasEq(<<(Foo::Assoc<'a, T>)<Self>> as Bar>::U = Ty) :- WC.
}

To be honest, I'm not entirely sure if AssociatedTyDatum::to_program_clauses() is the best place to generate those clauses in, but analogous clauses for placeholder opaque types are generated in OpaqueTyDatum::to_program_clauses(), which I modeled after.

Spotted in rust-lang/rust-analyzer#14680.

@lowr lowr force-pushed the fix/clauses-for-assoc-placeholders branch from 4699940 to 5ffee10 Compare April 30, 2023 15:00
@jackh726
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 13, 2023

📌 Commit 5ffee10 has been approved by jackh726

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jun 13, 2023

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout fix/clauses-for-assoc-placeholders (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self fix/clauses-for-assoc-placeholders --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
Auto-merging tests/test/projection.rs
CONFLICT (content): Merge conflict in tests/test/projection.rs
Auto-merging chalk-solve/src/clauses.rs
Automatic merge failed; fix conflicts and then commit the result.

@bors
Copy link
Contributor

bors commented Jun 13, 2023

☔ The latest upstream changes (presumably #780) made this pull request unmergeable. Please resolve the merge conflicts.

@lowr
Copy link
Contributor Author

lowr commented Jun 13, 2023

I'll rebase this one after #792 lands as it's likely to cause another conflict.

@lowr lowr force-pushed the fix/clauses-for-assoc-placeholders branch from 5ffee10 to 52b52cf Compare June 14, 2023 10:46
@jackh726
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Jun 14, 2023

📌 Commit 52b52cf has been approved by jackh726

It is now in the queue for this repository.

@bors
Copy link
Contributor

bors commented Jun 14, 2023

⌛ Testing commit 52b52cf with merge e856e21...

@bors
Copy link
Contributor

bors commented Jun 14, 2023

☀️ Test successful - checks-actions
Approved by: jackh726
Pushing e856e21 to master...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants