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

Consider mutations as borrows in generator drop tracking #94068

Merged
merged 1 commit into from
Feb 25, 2022

Conversation

eholk
Copy link
Contributor

@eholk eholk commented Feb 16, 2022

This is needed to match MIR more conservative approximation of any borrowed value being live across a suspend point (See #94067). This change considers an expression such as x.y = z to be a borrow of x and therefore keeps x live across suspend points.

r? @nikomatsakis

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Feb 16, 2022
@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Feb 16, 2022
@rust-log-analyzer

This comment has been minimized.

This is needed to match MIR more conservative approximation of any
borrowed value being live across a suspend point (See rust-lang#94067). This
change considers an expression such as `x.y = z` to be a borrow of `x`
and therefore keeps `x` live across suspend points.
@tmandry tmandry self-assigned this Feb 22, 2022
@tmandry
Copy link
Member

tmandry commented Feb 25, 2022

@bors r+ rollup

@bors
Copy link
Contributor

bors commented Feb 25, 2022

📌 Commit 074d757 has been approved by tmandry

@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 25, 2022
bors added a commit to rust-lang-ci/rust that referenced this pull request Feb 25, 2022
…askrgr

Rollup of 6 pull requests

Successful merges:

 - rust-lang#92714 (Provide ignore message in the result of test)
 - rust-lang#93273 (Always check cg_llvm with ./x.py check)
 - rust-lang#94068 (Consider mutations as borrows in generator drop tracking)
 - rust-lang#94184 (BTree: simplify test code)
 - rust-lang#94297 (update const_generics_defaults release notes)
 - rust-lang#94341 (Remove a duplicate space)

Failed merges:

r? `@ghost`
`@rustbot` modify labels: rollup
@bors bors merged commit 1007011 into rust-lang:master Feb 25, 2022
@rustbot rustbot added this to the 1.61.0 milestone Feb 25, 2022
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 5, 2022
… r=tmiasko

Reenable generator drop tracking tests and fix mutation handling

The previous PR, rust-lang#94068, was overly zealous in counting mutations as borrows, which effectively nullified drop tracking. We would have caught this except the drop tracking tests were still ignored, despite having the option of using the `-Zdrop-tracking` flag now.

This PR fixes the issue introduced by rust-lang#94068 by only counting mutations as borrows the mutated place has a project. This is sufficient to distinguish `x.y = 42` (which should count as a borrow of `x`) from `x = 42` (which is not a borrow of `x` because the whole variable is overwritten).

This PR also re-enables the drop tracking regression tests using the `-Zdrop-tracking` flag so we will avoid introducing these sorts of issues in the future.

Thanks to `@tmiasko` for noticing this problem and pointing it out!

r? `@tmiasko`
Dylan-DPC added a commit to Dylan-DPC/rust that referenced this pull request Mar 5, 2022
… r=tmiasko

Reenable generator drop tracking tests and fix mutation handling

The previous PR, rust-lang#94068, was overly zealous in counting mutations as borrows, which effectively nullified drop tracking. We would have caught this except the drop tracking tests were still ignored, despite having the option of using the `-Zdrop-tracking` flag now.

This PR fixes the issue introduced by rust-lang#94068 by only counting mutations as borrows the mutated place has a project. This is sufficient to distinguish `x.y = 42` (which should count as a borrow of `x`) from `x = 42` (which is not a borrow of `x` because the whole variable is overwritten).

This PR also re-enables the drop tracking regression tests using the `-Zdrop-tracking` flag so we will avoid introducing these sorts of issues in the future.

Thanks to ``@tmiasko`` for noticing this problem and pointing it out!

r? ``@tmiasko``
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
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.

7 participants