diff options
| author | Matthias Krüger <476013+matthiaskrgr@users.noreply.github.com> | 2025-03-15 11:29:27 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-15 11:29:27 +0100 |
| commit | 81ba55746dd7163ccc065cb0cec8172bdb3648f1 (patch) | |
| tree | ff0d15b7403072bf807f64e21fe917ffe03d6734 /compiler/rustc_codegen_llvm/src | |
| parent | 232ec5caeac4034f0ada5d7b159d86999f4d5aa0 (diff) | |
| parent | e54bde6d473941ff45643f494a902f23b19e7c9a (diff) | |
| download | rust-81ba55746dd7163ccc065cb0cec8172bdb3648f1.tar.gz rust-81ba55746dd7163ccc065cb0cec8172bdb3648f1.zip | |
Rollup merge of #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 #138501
r? oli-obk
Diffstat (limited to 'compiler/rustc_codegen_llvm/src')
0 files changed, 0 insertions, 0 deletions
