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

[compiler-v2] Ability constraints are not shallow #12674

Closed
wrwg opened this issue Mar 25, 2024 · 0 comments · Fixed by #12675
Closed

[compiler-v2] Ability constraints are not shallow #12674

wrwg opened this issue Mar 25, 2024 · 0 comments · Fixed by #12675
Labels
bug Something isn't working compiler-v2 stale-exempt Prevents issues from being automatically marked and closed as stale

Comments

@wrwg
Copy link
Contributor

wrwg commented Mar 25, 2024

The current type constraint mechanism of v2 assumes that a constraint can be resolved if a shallow binding of a type variable is provided. However, that is not true for ability constraints. Consider e.g. Box<tvar> -- we don't know the abilities of the shallow outer type unless we know the type tvar.

Since this seems to be a rare scenario, for now we bail out with an error "type annotation needed" if coming along this case. Instead, we may do full constraint derivation (which we need to do for traits anyway, eventually), by breaking down ability constraints for structured types into constraints of the components.

@wrwg wrwg added bug Something isn't working compiler-v2 labels Mar 25, 2024
wrwg added a commit that referenced this issue Mar 26, 2024
This concludes moving all ability checking into the type inference algorithm by representing checks as type constraints. It also introduces some new constraints to deal with some other checks which have done previously ad-hoc (whether types are allowed to be references, tuples, phantom).

The PR turned out to be a larger refactoring of the checker as expected. On the good side, a lot of redundant ad-hoc code could be removed and replaced by more generic code.

Closes #12437 and closes #12674
@sausagee sausagee added the stale-exempt Prevents issues from being automatically marked and closed as stale label Mar 26, 2024
wrwg added a commit that referenced this issue Mar 28, 2024
This concludes moving all ability checking into the type inference algorithm by representing checks as type constraints. It also introduces some new constraints to deal with some other checks which have done previously ad-hoc (whether types are allowed to be references, tuples, phantom).

The PR turned out to be a larger refactoring of the checker as expected. On the good side, a lot of redundant ad-hoc code could be removed and replaced by more generic code.

Closes #12437 and closes #12674
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working compiler-v2 stale-exempt Prevents issues from being automatically marked and closed as stale
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants