Matthias Krüger
6c898d2b03
Rollup merge of #129101 - compiler-errors:deref-on-parent-by-ref, r=lcnr
...
Fix projections when parent capture is by-ref but child capture is by-value in the `ByMoveBody` pass
This fixes a somewhat strange bug where we build the incorrect MIR in #129074 . This one is weird, but I don't expect it to actually matter in practice since it almost certainly results in a move error in borrowck. However, let's not ICE.
Given the code:
```
#![feature(async_closure)]
// NOT copy.
struct Ty;
fn hello(x: &Ty) {
let c = async || {
*x;
//~^ ERROR cannot move out of `*x` which is behind a shared reference
};
}
fn main() {}
```
The parent coroutine-closure captures `x: &Ty` by-ref, resulting in an upvar of `&&Ty`. The child coroutine captures `x` by-value, resulting in an upvar of `&Ty`. When constructing the by-move body for the coroutine-closure, we weren't applying an additional deref projection to convert the parent capture into the child capture, resulting in an type error in assignment, which is a validation ICE.
As I said above, this only occurs (AFAICT) in code that eventually results in an error, because it is only triggered by HIR that attempts to move a non-copy value out of a ref. This doesn't occur if `Ty` is `Copy`, since we'd instead capture `x` by-ref in the child coroutine.
Fixes #129074
2024-08-15 19:32:37 +02:00
..
2024-08-15 19:32:37 +02:00
2024-07-25 04:43:18 +02:00
2024-02-16 20:02:50 +00:00
2024-07-12 03:02:58 +00:00
2024-02-16 20:02:50 +00:00
2024-03-25 08:01:15 -07:00
2024-08-10 00:54:16 +00:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-07-18 08:09:01 +02:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-02-17 13:59:45 +01:00
2024-02-16 20:02:50 +00:00
2024-03-19 12:02:21 -04:00
2024-02-16 20:02:50 +00:00
2024-05-07 16:56:54 -04:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-27 15:19:08 -04:00
2024-04-10 13:39:53 -04:00
2024-04-10 13:39:53 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-05-29 12:57:01 +03:00
2024-04-16 20:45:07 +03:00
2024-02-16 20:02:50 +00:00
2024-03-03 18:53:35 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-05-21 19:05:37 -07:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-02-27 03:20:10 +00:00
2024-04-24 08:05:29 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-05-21 19:05:37 -07:00
2024-02-16 20:02:50 +00:00
2024-06-27 15:19:08 -04:00
2024-04-24 08:05:29 +00:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-04-11 11:56:47 -04:00
2024-05-20 20:16:29 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-07-28 22:31:13 +08:00
2024-07-28 22:31:13 +08:00
2024-07-28 22:31:13 +08:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-04-30 22:27:19 +02:00
2024-04-30 22:27:19 +02:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-07-04 02:02:21 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-02-09 15:43:08 -03:00
2024-02-09 15:43:08 -03:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-04-30 22:27:19 +02:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 04:28:05 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-12 20:26:34 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-04 14:19:42 -03:00
2024-06-04 14:19:42 -03:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-04-24 08:05:29 +00:00
2024-03-10 21:18:41 -04:00
2024-03-19 12:02:21 -04:00
2024-03-19 12:02:21 -04:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-05-28 20:05:01 +00:00
2024-05-28 20:48:35 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-03-19 11:30:12 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-24 16:20:22 -05:00
2024-06-24 16:20:22 -05:00
2024-02-17 16:49:01 +01:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-06-27 15:19:08 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-01-30 21:28:18 +00:00
2024-02-16 20:02:50 +00:00
2024-07-31 12:24:26 -04:00
2024-07-31 12:24:26 -04:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00
2024-02-16 20:02:50 +00:00