WIP: Trust parameter env when projecting GATs#98742
Closed
nikomatsakis wants to merge 2 commits intorust-lang:masterfrom
Closed
WIP: Trust parameter env when projecting GATs#98742nikomatsakis wants to merge 2 commits intorust-lang:masterfrom
nikomatsakis wants to merge 2 commits intorust-lang:masterfrom
Conversation
If the param-env tells you that, forall 'a, `T::Item<'a> = u32`, we can believe it.
`call-forall` shows the expected behavior: the where-clause proves too much, so we can't prove it. `backwards-incompat` shows the problem with that: we can construct types that we ought not to be able to construct.
Contributor
Author
|
Thinking on it more, as the backwards-incompat suggests, this behavior isn't more right -- that is, I think we should be trusting the where-clause, but we have the wrong where-clause, so... in a way the current code enforces something closer to the final behavior (but not completely). Anyway, prob shouldn't land, but it was a good exercise for me. |
Collaborator
|
☔ The latest upstream changes (presumably #93967) made this pull request unmergeable. Please resolve the merge conflicts. |
Member
|
Closing this as it was an experiment |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
While investigating the behavior for GAT implied bounds, I realized that we were enforcing stricter requirements when projecting than I believe we should -- in particular, if the where-clause says "this is true for all
'a", we should believe it.This fixes a lot of unnecessary errors from GATs, though not all (see the new test I added, which shows why this is still sound and reasonable).
However, it also may introduce a backwards incompatibility hazard, albeit a very unlikely one, in that we are going to modify the meaning of this where-clause, and hence some functions are accepted now that won't be accepted later, even though they aren't callable today.
r? @jackh726