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

Allow tests to override the default closure impls #733

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

JakobDegen
Copy link
Contributor

In tests, closures can now have explicit Fn* impls, in which case the default impls will no longer be emitted for that closure. These types of impls are restricted to being non-generic over the type. This allows reproducing #688 in a chalk test.

The mechanism for this is an absolute hack; if there's any impl Fn* for MyClosure then the parser will generate a custom LocalImplAllowed clause which is later searched for during WF checking of impls and before emitting default closure impls for that type. The upside of this is that we can re-use the plumbing on the chalk-solve side, especially the WF checking. This probably breaks coherence checking for Fn* traits in tests, but that doesn't seem like an issue.

In tests, closures can now explicitly specify `Fn*` impls, in which
case the default impls will no longer be emitted. These types of
impls are restricted to being non-generic over the type.
@bors
Copy link
Contributor

bors commented Mar 9, 2022

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

@@ -110,6 +110,21 @@ pub fn add_fn_trait_program_clauses<I: Interner>(
Ok(())
}
TyKind::Closure(closure_id, substitution) => {
for custom in db.custom_clauses() {
if let DomainGoal::LocalImplAllowed(tr) =
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wait, why do we have to add this LocalImplAllowed? I'm fine with funky testing frameworks, but this seems to be a bit more invasive to the "lower layers" than I would like.

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