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 mir borrowck's use of opaque types independent of the typeck query's result #87287

Merged
merged 7 commits into from
Jul 23, 2021

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jul 19, 2021

fixes #87218
fixes #86465

we used to use the typeck results only to generate an obligation for the mir borrowck type to be equal to the typeck result.

When i removed the fixup_opaque_types function in #87200, I exposed a bug that showed that mir borrowck can't doesn't get enough information from typeck in order to build the correct lifetime mapping from opaque type usage to the actual concrete type. We therefor now fully compute the information within mir borrowck (we already did that, but we only used it to verify the typeck result) and stop using the typeck information.

We will likely be able to remove most opaque type information from the borrowck results in the future and just have all current callers use the mir borrowck result instead.

r? @spastorino

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jul 19, 2021
@rust-log-analyzer

This comment has been minimized.

@lqd

This comment has been minimized.

@oli-obk

This comment has been minimized.

@bors
Copy link
Contributor

bors commented Jul 20, 2021

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

@oli-obk oli-obk force-pushed the fixup_fixup_fixup_opaque_types branch from 2db308c to 75d9ed7 Compare July 20, 2021 10:11
Copy link
Contributor

@b-naber b-naber left a comment

Choose a reason for hiding this comment

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

Not sure whether I'm qualified enough to review this, I might be missing something, but there were two parts I didn't understand.

cx.opaque_type_values
let mut opaque_type_values = cx.opaque_type_values;

for (_, revealed_ty) in &mut opaque_type_values {
Copy link
Contributor

Choose a reason for hiding this comment

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

Why does opaque_type_values contain elements at the start of the loop? It seems to me that the only place where elements were inserted into this field was in the code you deleted below?

Copy link
Contributor Author

@oli-obk oli-obk Jul 20, 2021

Choose a reason for hiding this comment

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

yes, but the function where I deleted code is called multiple times. The opaque types are collected over time.

compiler/rustc_mir/src/borrow_check/type_check/mod.rs Outdated Show resolved Hide resolved
@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the fixup_fixup_fixup_opaque_types branch from 3d70dee to 5156aab Compare July 20, 2021 15:34
@spastorino
Copy link
Member

Looks good to me, bors r=me once tests are 👍

@rust-log-analyzer

This comment has been minimized.

@oli-obk oli-obk force-pushed the fixup_fixup_fixup_opaque_types branch from 5156aab to 713044c Compare July 20, 2021 16:03
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 20, 2021

@bors r=spastorino

@bors
Copy link
Contributor

bors commented Jul 20, 2021

📌 Commit 713044c has been approved by spastorino

@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 Jul 20, 2021
@rust-log-analyzer

This comment has been minimized.

@spastorino
Copy link
Member

@bors retry

@spastorino spastorino closed this Jul 20, 2021
@spastorino spastorino reopened this Jul 20, 2021
@spastorino
Copy link
Member

@bors retry

@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 20, 2021

@bors r=spastorino

@bors
Copy link
Contributor

bors commented Jul 20, 2021

💡 This pull request was already approved, no need to approve it again.

@bors
Copy link
Contributor

bors commented Jul 20, 2021

📌 Commit 713044c has been approved by spastorino

Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jul 21, 2021
…pes, r=spastorino

 Make mir borrowck's use of opaque types independent of the typeck query's result

fixes rust-lang#87218
fixes rust-lang#86465

we used to use the typeck results only to generate an obligation for the mir borrowck type to be equal to the typeck result.

When i removed the `fixup_opaque_types` function in rust-lang#87200, I exposed a bug that showed that mir borrowck can't doesn't get enough information from typeck in order to build the correct lifetime mapping from opaque type usage to the actual concrete type. We therefor now fully compute the information within mir borrowck (we already did that, but we only used it to verify the typeck result) and stop using the typeck information.

We will likely be able to remove most opaque type information from the borrowck results in the future and just have all current callers use the mir borrowck result instead.

r? `@spastorino`
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Jul 21, 2021
…pes, r=spastorino

 Make mir borrowck's use of opaque types independent of the typeck query's result

fixes rust-lang#87218
fixes rust-lang#86465

we used to use the typeck results only to generate an obligation for the mir borrowck type to be equal to the typeck result.

When i removed the `fixup_opaque_types` function in rust-lang#87200, I exposed a bug that showed that mir borrowck can't doesn't get enough information from typeck in order to build the correct lifetime mapping from opaque type usage to the actual concrete type. We therefor now fully compute the information within mir borrowck (we already did that, but we only used it to verify the typeck result) and stop using the typeck information.

We will likely be able to remove most opaque type information from the borrowck results in the future and just have all current callers use the mir borrowck result instead.

r? ``@spastorino``
It used to allow you to mutate the key, even though that can invalidate the map by creating duplicate keys.
I attempted that with the previous code, but I misunderstdood how
`shallow_resolve` works.
@oli-obk oli-obk force-pushed the fixup_fixup_fixup_opaque_types branch from 713044c to d103852 Compare July 22, 2021 11:26
@oli-obk
Copy link
Contributor Author

oli-obk commented Jul 22, 2021

@bors r=spastorino

@bors
Copy link
Contributor

bors commented Jul 22, 2021

📌 Commit d103852 has been approved by spastorino

@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 Jul 22, 2021
@bors
Copy link
Contributor

bors commented Jul 23, 2021

⌛ Testing commit d103852 with merge b2b7c85...

@bors
Copy link
Contributor

bors commented Jul 23, 2021

☀️ Test successful - checks-actions
Approved by: spastorino
Pushing b2b7c85 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 23, 2021
@bors bors merged commit b2b7c85 into rust-lang:master Jul 23, 2021
@rustbot rustbot added this to the 1.55.0 milestone Jul 23, 2021
JohnTitor added a commit to JohnTitor/rust that referenced this pull request Jul 23, 2021
…i-obk

VecMap::get_value_matching should return just one element

r? `@nikomatsakis`

Related to rust-lang#86465 and rust-lang#87287
GuillaumeGomez added a commit to GuillaumeGomez/rust that referenced this pull request Jul 29, 2021
Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution

Fixes rust-lang#87455

This situation was unreachable before rust-lang#87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After rust-lang#87287 we let the `InferCx` in mir borrowck figure out the opaque type all by itself (which it already did before, but it only used the result to sanity check with the typeck result).
fee1-dead added a commit to fee1-dead-contrib/rust that referenced this pull request Jul 29, 2021
Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution

Fixes rust-lang#87455

This situation was unreachable before rust-lang#87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After rust-lang#87287 we let the `InferCx` in mir borrowck figure out the opaque type all by itself (which it already did before, but it only used the result to sanity check with the typeck result).
bors added a commit to rust-lang-ci/rust that referenced this pull request Jul 30, 2021
Mir borrowck does not generate lifetime variables for 'static lifetimes during opaque type resolution

Fixes rust-lang#87455

This situation was unreachable before rust-lang#87287 as we used to just grab the resolved opaque type from typeck and replaced all regions with new inference vars. After rust-lang#87287 we let the `InferCx` in mir borrowck figure out the opaque type all by itself (which it already did before, but it only used the result to sanity check with the typeck result).
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 31, 2021
Concrete regions can show up in mir borrowck if the originated from there

We used to not encounter them here, because we took regions from typeck's opaque type resolution by renumbering them. We don't do that anymore. Instead mir borrock does all the logic, and it can handle concrete regions just fine, as long as it created them itself.

fixes rust-lang#83190 which was introduced by rust-lang#87287

r? `@spastorino`
@oli-obk oli-obk deleted the fixup_fixup_fixup_opaque_types branch November 9, 2022 09:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.
Projects
None yet
8 participants