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

Projects
None yet
8 participants
@nikomatsakis
Copy link
Contributor

nikomatsakis commented Feb 1, 2019

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

This comment has been minimized.

Copy link
Contributor Author

nikomatsakis commented Feb 1, 2019

(Still running tests locally)

@nikomatsakis nikomatsakis force-pushed the nikomatsakis:issue-57843-universe-leak branch from 82070f0 to 02465f1 Feb 1, 2019

@Dylan-DPC

This comment has been minimized.

Copy link
Member

Dylan-DPC commented Feb 11, 2019

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

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Feb 14, 2019

I'll prioritize the review here.

nikomatsakis added some commits Feb 1, 2019

print more information for closures when `-Zverbose` is given
Ideally, we'd probably print the closure substs themselves actually.
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.
@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Feb 15, 2019

r=me

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Feb 15, 2019

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 pnkfelix force-pushed the nikomatsakis:issue-57843-universe-leak branch from 02465f1 to 9661ee6 Feb 15, 2019

@pnkfelix

This comment has been minimized.

Copy link
Member

pnkfelix commented Feb 15, 2019

@bors r+

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 15, 2019

📌 Commit 9661ee6 has been approved by pnkfelix

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 15, 2019

⌛️ Testing commit 9661ee6 with merge 0a71da2...

bors added a commit that referenced this pull request Feb 15, 2019

Auto merge of #58056 - nikomatsakis:issue-57843-universe-leak, r=pnkf…
…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

This comment has been minimized.

Copy link
Contributor

bors commented Feb 15, 2019

💔 Test failed - checks-travis

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 15, 2019

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)

@pietroalbini

This comment has been minimized.

Copy link
Member

pietroalbini commented Feb 15, 2019

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

@nikomatsakis

This comment has been minimized.

Copy link
Contributor Author

nikomatsakis commented Feb 19, 2019

@bors p=1

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

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 19, 2019

⌛️ Testing commit 9661ee6 with merge 08adf37...

bors added a commit that referenced this pull request Feb 19, 2019

Auto merge of #58056 - nikomatsakis:issue-57843-universe-leak, r=pnkf…
…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

This comment has been minimized.

Copy link
Contributor

bors commented Feb 19, 2019

💔 Test failed - status-appveyor

@rust-highfive

This comment has been minimized.

Copy link
Collaborator

rust-highfive commented Feb 20, 2019

The job arm-android of 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.
[01:46:59] test vec::test_split_at_mut ... ok
[01:46:59] test vec::test_split_off ... ok
[01:46:59] test vec::test_splice_unbounded ... ok
[01:46:59] test vec::test_swap_remove_empty ... ok
[01:46:59] died due to signal 11
[01:47:00] 
[01:47:00] 
[01:47:00] command did not execute successfully: "/checkout/obj/build/x86_64-unknown-linux-gnu/stage0/bin/cargo" "test" "--target" "arm-linux-androideabi" "-j" "4" "--release" "--locked" "--color" "always" "--features" "panic-unwind backtrace" "--manifest-path" "/checkout/src/libstd/Cargo.toml" "-p" "alloc" "--"
[01:47:00] expected success, got: exit code: 3
---
travis_time:end:17e61420:start=1550674082585479089,finish=1550674082592962614,duration=7483525
travis_fold:end:after_failure.3
travis_fold:start:after_failure.4
travis_time:start:013e43c5
$ ln -s . checkout && for CORE in obj/cores/core.*; do EXE=$(echo $CORE | sed 's|obj/cores/core\.[0-9]*\.!checkout!\(.*\)|\1|;y|!|/|'); if [ -f "$EXE" ]; then printf travis_fold":start:crashlog\n\033[31;1m%s\033[0m\n" "$CORE"; gdb --batch -q -c "$CORE" "$EXE" -iex 'set auto-load off' -iex 'dir src/' -iex 'set sysroot .' -ex bt -ex q; echo travis_fold":"end:crashlog; fi; done || true
travis_fold:end:after_failure.4
travis_fold:start:after_failure.5
travis_time:start:14534314
travis_time:start:14534314
$ cat ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers || true
cat: ./obj/build/x86_64-unknown-linux-gnu/native/asan/build/lib/asan/clang_rt.asan-dynamic-i386.vers: No such file or directory
travis_fold:end:after_failure.5
travis_fold:start:after_failure.6
travis_time:start:1fbda7cc
$ dmesg | grep -i kill

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)

@pietroalbini

This comment has been minimized.

Copy link
Member

pietroalbini commented Feb 20, 2019

@bors retry #55861

@bors

This comment has been minimized.

Copy link
Contributor

bors commented Feb 20, 2019

⌛️ Testing commit 9661ee6 with merge f53e950...

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

Auto merge of #58056 - nikomatsakis:issue-57843-universe-leak, r=pnkf…
…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

This comment has been minimized.

Copy link
Contributor

bors commented Feb 20, 2019

💔 Test failed - status-appveyor

@kennytm

This comment has been minimized.

Copy link
Member

kennytm commented Feb 20, 2019

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

Auto merge of #58592 - nikomatsakis:universe-leak-check, r=<try>
[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

This comment has been minimized.

Copy link
Member

Mark-Simulacrum commented Feb 20, 2019

#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

This comment has been minimized.

Copy link
Contributor Author

nikomatsakis commented Feb 20, 2019

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

@bors

This comment has been minimized.

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

Auto merge of #58056 - nikomatsakis:issue-57843-universe-leak, r=pnkf…
…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

This comment has been minimized.

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 label Feb 21, 2019

@bors bors merged commit 9661ee6 into rust-lang:master Feb 21, 2019

1 check passed

homu Test successful
Details

bors added a commit that referenced this pull request Feb 21, 2019

Auto merge of #58592 - nikomatsakis:universe-leak-check, r=aturon
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.~~

bors added a commit that referenced this pull request Feb 21, 2019

Auto merge of #58592 - nikomatsakis:universe-leak-check, r=aturon
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.~~

bors added a commit that referenced this pull request Feb 21, 2019

Auto merge of #58592 - nikomatsakis:universe-leak-check, r=aturon
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.~~

bors added a commit that referenced this pull request Feb 21, 2019

Auto merge of #58592 - nikomatsakis:universe-leak-check, r=aturon
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.~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment