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

make generalization code create new variables in correct universe #58056

Merged
merged 4 commits into from
Feb 21, 2019

Conversation

nikomatsakis
Copy link
Contributor

In our type inference system, when we "generalize" a type T to become
a suitable value for a type variable V, we sometimes wind up creating
new inference variables. So, for example, if we are making V be some
subtype of &'X u32, then we might instantiate V with &'Y u32.
This generalized type is then related &'Y u32 <: &'X u32, resulting
in a region constriant 'Y: 'X. Previously, however, we were making
these fresh variables like 'Y in the "current universe", but they
should be created in the universe of V. Moreover, we sometimes cheat
in an invariant context and avoid creating fresh variables if we know
the result must be equal -- we can only do that when the universes
work out.

Fixes #57843

r? @pnkfelix

@nikomatsakis
Copy link
Contributor Author

(Still running tests locally)

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 1, 2019
@Dylan-DPC-zz
Copy link

ping from triage @nikomatsakis @pnkfelix what's the update on this?

@pnkfelix
Copy link
Member

I'll prioritize the review here.

Ideally, we'd probably print the closure substs themselves actually.
In our type inference system, when we "generalize" a type T to become
a suitable value for a type variable V, we sometimes wind up creating
new inference variables. So, for example, if we are making V be some
subtype of `&'X u32`, then we might instantiate V with `&'Y u32`.
This generalized type is then related `&'Y u32 <: &'X u32`, resulting
in a region constriant `'Y: 'X`. Previously, however, we were making
these fresh variables like `'Y` in the "current universe", but they
should be created in the universe of V. Moreover, we sometimes cheat
in an invariant context and avoid creating fresh variables if we know
the result must be equal -- we can only do that when the universes
work out.
@pnkfelix
Copy link
Member

r=me

@pnkfelix
Copy link
Member

The merge conflicts are with PR #57901, Interestingly (at least to me), it seems like the changes from this PR, once rebased, cause those cases to "revert" to the messages that we used to get prior to PR #57901. Which one might consider to be a slight regression...

@pnkfelix
Copy link
Member

@bors r+

@bors
Copy link
Contributor

bors commented Feb 15, 2019

📌 Commit 9661ee6 has been approved by pnkfelix

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2019
@bors
Copy link
Contributor

bors commented Feb 15, 2019

⌛ Testing commit 9661ee6 with merge 0a71da25710b5fdfd90a31c35e8d2313986243c1...

@bors
Copy link
Contributor

bors commented Feb 15, 2019

💔 Test failed - checks-travis

@rust-highfive
Copy link
Collaborator

Your PR failed on Travis (raw log). Through arcane magic we have determined that the following fragments from the build log may contain information about the problem.

Click to expand the log.

I'm a bot! I can only do what humans tell me to, so if this was not helpful or you have suggestions for improvements, please ping or otherwise contact @TimNN. (Feature Requests)

@bors bors added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Feb 15, 2019
@pietroalbini
Copy link
Member

@bors retry -- apparently we can't clone the repo anymore on macOS

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 15, 2019
@nikomatsakis
Copy link
Contributor Author

@bors p=1

Soundness bug, urgent-ish to get this stuff landed.

@bors
Copy link
Contributor

bors commented Feb 19, 2019

⌛ Testing commit 9661ee6 with merge 08adf37b53626653cef443887b55132e715926a0...

@bors
Copy link
Contributor

bors commented Feb 19, 2019

💔 Test failed - status-appveyor

@kennytm
Copy link
Member

kennytm commented Feb 20, 2019

@bors retry p=1 rust-lang/rls#1265

@bors bors added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 20, 2019
bors added a commit that referenced this pull request Feb 20, 2019
[WIP] Re-implement leak check in terms of universes

This PR temporarily restores the leak-check, but implemented in terms of universes. This is not because the leak check behavior was necessarily **correct**, but because (a) we may want to have a transition period and because (b) we want to have more breathing room to work through the full implications of handling higher-ranked types correctly. Note that this PR builds atop #58056.

Fixes #58451
Fixes #46989
Fixes #57639

r? @aturon
cc @arielb1, @lqd

~~Temporary note: I've not finished running `./x.py test` locally -- I'm confident a lot of error messages in tests will need updating. I sort of expect them to revert to the older, (imo) less good error messages, which is mildly unfortunate. There might be a way to preserve the new error messages, not sure.~~
@Mark-Simulacrum Mark-Simulacrum added I-nominated beta-nominated Nominated for backporting to the compiler in the beta channel. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Feb 20, 2019
@Mark-Simulacrum
Copy link
Member

#58592 depends on this so this will also need to be backported to beta (to be released in one week). Nominating for compiler team to approve.

@nikomatsakis
Copy link
Contributor Author

Thanks @Mark-Simulacrum. I was actually just coming to nominate it regardless -- it is an important soundness fix.

@bors
Copy link
Contributor

bors commented Feb 20, 2019

⌛ Testing commit 9661ee6 with merge 1349c84...

bors added a commit that referenced this pull request Feb 20, 2019
…elix

make generalization code create new variables in correct universe

In our type inference system, when we "generalize" a type T to become
a suitable value for a type variable V, we sometimes wind up creating
new inference variables. So, for example, if we are making V be some
subtype of `&'X u32`, then we might instantiate V with `&'Y u32`.
This generalized type is then related `&'Y u32 <: &'X u32`, resulting
in a region constriant `'Y: 'X`. Previously, however, we were making
these fresh variables like `'Y` in the "current universe", but they
should be created in the universe of V. Moreover, we sometimes cheat
in an invariant context and avoid creating fresh variables if we know
the result must be equal -- we can only do that when the universes
work out.

Fixes #57843

r? @pnkfelix
@bors
Copy link
Contributor

bors commented Feb 21, 2019

☀️ Test successful - checks-travis, status-appveyor
Approved by: pnkfelix
Pushing 1349c84 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Feb 21, 2019
@bors bors merged commit 9661ee6 into rust-lang:master Feb 21, 2019
bors added a commit that referenced this pull request Feb 21, 2019
Re-implement leak check in terms of universes

This PR temporarily restores the leak-check, but implemented in terms of universes. This is not because the leak check behavior was necessarily **correct**, but because (a) we may want to have a transition period and because (b) we want to have more breathing room to work through the full implications of handling higher-ranked types correctly. Note that this PR builds atop #58056.

Fixes #58451
Fixes #46989
Fixes #57639

r? @aturon
cc @arielb1, @lqd

~~Temporary note: I've not finished running `./x.py test` locally -- I'm confident a lot of error messages in tests will need updating. I sort of expect them to revert to the older, (imo) less good error messages, which is mildly unfortunate. There might be a way to preserve the new error messages, not sure.~~
@pnkfelix
Copy link
Member

We failed to discuss this beta-nomination separately from PR #58592 in yesterday's T-compiler meeting.

But as I understand it, PR #58592 depends on this PR.

Therefore I am going to mark this as beta-accepted.

@pnkfelix pnkfelix added beta-accepted Accepted for backporting to the compiler in the beta channel. and removed I-nominated labels Feb 22, 2019
bors added a commit that referenced this pull request Feb 22, 2019
[BETA] Universe leak check

Backport of #58592 and #58056 to beta.
@Mark-Simulacrum Mark-Simulacrum mentioned this pull request Feb 22, 2019
@pietroalbini pietroalbini removed the beta-nominated Nominated for backporting to the compiler in the beta channel. label Feb 22, 2019
bors added a commit that referenced this pull request Feb 23, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
beta-accepted Accepted for backporting to the compiler in the beta channel. merged-by-bors This PR was explicitly merged by bors. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants