-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Remove fake borrows of refs that are converted into non-refs in MakeByMoveBody
#138514
Merged
bors
merged 1 commit into
rust-lang:master
from
compiler-errors:fake-borrow-ref-to-value
Mar 15, 2025
Merged
Remove fake borrows of refs that are converted into non-refs in MakeByMoveBody
#138514
bors
merged 1 commit into
rust-lang:master
from
compiler-errors:fake-borrow-ref-to-value
Mar 15, 2025
Conversation
This file contains 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
Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt |
compiler-errors
commented
Mar 14, 2025
621bb79
to
e54bde6
Compare
@bors r+ rollup |
bors
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 15, 2025
…iaskrgr Rollup of 5 pull requests Successful merges: - rust-lang#138283 (Enforce type of const param correctly in MIR typeck) - rust-lang#138439 (feat: check ARG_MAX on Unix platforms) - rust-lang#138502 (resolve: Avoid some unstable iteration) - rust-lang#138514 (Remove fake borrows of refs that are converted into non-refs in `MakeByMoveBody`) - rust-lang#138524 (Mark myself as unavailable for reviews temporarily) r? `@ghost` `@rustbot` modify labels: rollup
rust-timer
added a commit
to rust-lang-ci/rust
that referenced
this pull request
Mar 15, 2025
Rollup merge of rust-lang#138514 - compiler-errors:fake-borrow-ref-to-value, r=oli-obk Remove fake borrows of refs that are converted into non-refs in `MakeByMoveBody` Remove fake borrows of closure captures if that capture has been replaced with a by-move version of that capture. For example, given an async closure that looks like: ``` let f: Foo; let c = async move || { match f { ... } }; ``` ... in this pair of coroutine-closure + coroutine, we capture `Foo` in the parent and `&Foo` in the child. We will emit two fake borrows like: ``` _2 = &fake shallow (*(_1.0: &Foo)); _3 = &fake shallow (_1.0: &Foo); ``` However, since the by-move-body transform is responsible for replacing `_1.0: &Foo` with `_1.0: Foo` (since the `AsyncFnOnce` coroutine will own `Foo` by value), that makes the second fake borrow obsolete since we never have an upvar of type `&Foo`, and we should replace it with a `nop`. As a side-note, we don't actually even care about fake borrows here at all since they're fully a MIR borrowck artifact, and we don't need to borrowck by-move MIR bodies. But it's best to preserve as much as we can between these two bodies :) Fixes rust-lang#138501 r? oli-obk
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.
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.
Remove fake borrows of closure captures if that capture has been replaced with a by-move version of that capture.
For example, given an async closure that looks like:
... in this pair of coroutine-closure + coroutine, we capture
Foo
in the parent and&Foo
in the child. We will emit two fake borrows like:However, since the by-move-body transform is responsible for replacing
_1.0: &Foo
with_1.0: Foo
(since theAsyncFnOnce
coroutine will ownFoo
by value), that makes the second fake borrow obsolete since we never have an upvar of type&Foo
, and we should replace it with anop
.As a side-note, we don't actually even care about fake borrows here at all since they're fully a MIR borrowck artifact, and we don't need to borrowck by-move MIR bodies. But it's best to preserve as much as we can between these two bodies :)
Fixes #138501
r? oli-obk