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-09 19:35:02 +08:00
2024-03-11 09:36:35 -07:00
2024-03-11 09:36:35 -07:00
2024-07-18 00:19:27 +00:00
2024-05-04 11:30:38 +02:00
2024-07-22 22:51:53 +00:00
2024-07-28 03:11:54 +08:00
2024-08-13 23:18:31 +02:00
2024-07-18 11:58:16 +02:00
2024-07-23 01:48:03 +02:00
2024-07-29 21:47:19 -04:00
2024-07-26 14:41:56 -04:00
2024-08-15 19:32:37 +02:00
2024-08-07 20:49:02 -05:00
2024-07-24 17:19:44 -04:00
2024-05-20 19:55:59 -07:00
2024-07-30 08:16:47 +02:00
2024-05-02 19:42:31 -04:00
2024-07-26 14:41:56 -04:00
2024-07-18 00:00:04 +00:00
2024-07-26 14:41:56 -04:00
2024-04-24 22:21:15 +00:00
2024-07-26 14:41:56 -04:00
2024-07-14 13:50:09 +09:00
2024-08-14 05:05:51 +02:00
2024-08-07 14:08:34 +02:00
2024-08-02 02:29:15 +05:30
2024-02-29 15:27:59 -03:00
2024-08-10 12:07:17 +02:00
2024-07-18 14:32:10 +02:00
2024-07-19 23:27:42 +03:00
2024-08-10 12:07:17 +02:00
2024-08-06 18:24:17 -07:00
2024-08-03 07:57:31 -04:00
2024-03-11 09:36:35 -07:00
2024-07-06 21:00:30 +08:00
2024-04-07 17:06:15 +00:00
2024-07-12 03:02:57 +00:00
2024-05-28 11:55:20 +00:00
2024-08-10 16:23:55 +02:00
2024-08-01 14:25:19 +02:00
2024-08-13 04:32:34 +00:00
2024-08-12 19:27:57 -07:00
2024-07-12 03:02:57 +00:00
2024-03-06 18:19:13 -05:00
2024-03-18 16:08:58 +00:00
2024-06-04 22:50:35 +02:00
2024-03-07 14:26:31 +00:00
2024-07-11 12:23:44 +10:00
2024-08-10 00:54:16 +00:00
2024-06-22 17:06:47 +00:00
2024-06-14 20:25:17 +02:00
2024-04-21 15:43:43 -03:00
2024-08-05 05:40:19 +02:00
2024-08-13 04:26:48 +08:00
2024-08-09 22:02:23 -04:00
2024-04-25 10:48:11 +03:00
2024-07-12 03:02:57 +00:00
2024-07-18 18:39:20 +00:00
2024-07-31 23:20:12 +02:00
2024-07-18 00:00:04 +00:00
2024-04-22 11:51:50 -04:00
2024-05-09 14:47:09 +10:00
2024-06-13 21:47:43 -04:00
2024-07-18 18:20:35 +00:00
2024-03-06 12:01:54 +00:00
2024-07-18 18:20:35 +00:00
2024-08-10 12:07:17 +02:00
2024-03-17 21:59:40 +00:00
2024-08-10 00:54:16 +00:00
2024-04-27 10:54:31 +03:00
2024-07-22 10:12:00 -04:00
2024-07-07 18:16:38 +02:00
2024-07-18 18:20:35 +00:00
2024-08-02 11:34:54 +00:00
2024-06-11 09:14:34 +01:00
2024-08-15 00:02:25 +02:00
2024-05-20 19:55:59 -07:00
2024-07-12 03:02:57 +00:00
2024-08-05 09:55:14 -04:00
2024-05-20 19:55:59 -07:00
2024-05-16 21:08:42 -04:00
2024-04-30 12:46:59 +05:30
2024-05-20 19:55:59 -07:00
2024-05-20 19:55:59 -07:00
2024-04-12 20:57:07 +00:00
2024-08-10 16:23:55 +02:00
2024-07-17 11:01:29 +01:00
2024-07-22 22:51:53 +00:00
2024-07-12 03:02:57 +00:00
2024-03-06 12:35:07 -08:00
2024-08-13 16:23:20 -04:00
2024-08-02 11:34:54 +00:00
2024-05-24 11:20:33 -04:00
2024-08-13 16:23:20 -04:00
2024-07-13 13:12:52 +00:00
2024-08-01 18:53:42 +00:00
2024-03-29 18:22:44 -07:00
2024-06-21 19:00:18 -04:00
2024-06-01 09:40:46 +08:00
2024-07-29 22:29:34 +08:00
2024-06-26 16:01:45 +00:00
2024-08-08 00:41:39 +08:00
2024-06-21 19:00:18 -04:00
2024-02-26 11:10:18 +01:00
2024-04-15 08:54:11 -04:00
2024-07-31 20:26:20 +02:00
2024-04-25 07:58:31 +02:00
2024-07-11 12:23:44 +10:00
2024-08-05 17:37:12 -07:00
2024-07-12 21:16:09 -04:00
2024-08-06 04:08:10 +00:00
2024-07-29 23:49:51 +00:00
2024-06-12 20:57:23 -04:00
2024-07-12 03:02:57 +00:00
2024-07-25 15:14:42 -04:00
2024-07-22 22:51:53 +00:00
2024-07-24 18:00:35 +02:00
2024-07-19 18:53:40 +02:00
2024-07-12 03:22:32 +00:00
2024-07-18 20:08:38 +00:00
2024-08-05 05:40:19 +02:00
2024-07-11 12:23:44 +10:00
2024-06-29 13:02:59 +02:00
2024-08-09 11:36:01 +00:00
2024-07-04 02:02:21 +00:00
2024-06-20 04:25:17 +00:00
2024-04-29 14:53:38 +02:00
2024-07-21 13:45:55 -04:00
2024-03-01 17:51:29 +01:00
2024-07-31 23:20:09 +02:00
2024-07-18 20:08:38 +00:00
2024-05-28 12:31:33 +02:00
2024-03-31 20:44:30 -04:00
2024-07-05 11:17:49 -04:00
2024-05-20 11:13:10 -04:00
2024-07-29 17:46:43 +02:00
2024-07-21 21:42:10 +08:00
2024-07-17 16:22:26 +02:00
2024-04-21 20:10:12 -04:00
2024-04-07 17:38:07 -03:00
2024-07-26 14:41:56 -04:00
2024-07-04 02:02:21 +00:00
2024-06-13 20:22:21 +00:00
2024-07-11 12:23:44 +10:00
2024-08-10 12:07:17 +02:00
2024-07-26 14:41:56 -04:00
2024-06-16 03:41:57 -04:00
2024-07-18 18:20:35 +00:00
2024-03-20 17:29:58 +00:00
2024-07-26 00:57:20 +02:00
2024-08-08 11:58:11 -04:00
2024-06-12 12:34:47 +00:00
2024-07-12 03:02:57 +00:00
2024-07-24 08:46:52 +02:00
2024-07-11 12:23:44 +10:00
2024-07-11 12:23:44 +10:00
2024-05-28 12:31:12 +02:00
2024-08-02 11:34:54 +00:00
2024-08-09 05:52:53 +00:00
2024-06-27 22:24:36 +02:00
2024-08-13 23:00:42 +02:00
2024-08-08 20:53:25 -04:00
2024-04-11 17:53:27 -04:00
2024-04-24 08:05:29 +00:00
2024-08-01 18:53:42 +00:00
2024-08-12 13:00:12 +10:00
2024-08-02 11:34:54 +00:00
2024-03-06 12:35:07 -08:00
2024-08-03 07:57:31 -04:00
2024-07-12 03:02:57 +00:00
2024-05-03 15:56:59 +02:00
2024-08-10 12:07:17 +02:00
2024-07-12 21:16:09 -04:00
2024-08-03 07:57:31 -04:00
2024-07-11 20:39:24 +00:00
2024-07-11 12:23:44 +10:00
2024-07-29 23:49:51 +00:00
2024-06-30 23:11:54 -04:00
2024-08-10 15:13:38 +00:00
2024-05-28 12:31:12 +02:00
2024-08-09 16:16:16 -07:00
2024-05-23 09:07:59 +08:00
2024-08-14 14:04:11 +02:00
2024-05-19 20:09:03 -07:00
2024-07-18 20:08:38 +00:00
2024-08-12 14:59:50 -07:00
2024-07-18 13:33:38 +00:00
2024-05-04 11:30:38 +02:00
2024-07-24 21:03:27 +00:00
2024-03-09 18:24:45 +00:00
2024-07-02 16:31:40 +02:00
2024-08-01 18:53:42 +00:00
2024-08-10 00:54:16 +00:00
2024-06-30 17:08:45 +00:00
2024-07-29 09:50:07 +02:00
2024-08-05 09:55:14 -04:00
2024-08-05 17:37:12 -07:00
2024-07-16 19:27:28 -07:00
2024-04-28 16:10:12 -04:00
2024-04-28 16:10:12 -04:00
2024-07-18 20:08:38 +00:00
2024-08-05 17:56:50 -07:00
2024-08-03 07:57:31 -04:00
2024-08-10 05:27:17 +00:00
2024-07-17 11:01:29 +01:00
2024-05-24 17:44:37 -07:00
2024-08-07 00:41:48 -04:00
2024-07-15 22:21:41 +00:00
2024-07-11 00:18:47 +08:00
2024-03-06 12:35:07 -08:00
2024-05-23 13:44:56 +02:00
2024-07-10 18:56:06 -04:00
2024-07-11 12:23:44 +10:00
2024-07-14 17:46:25 +05:30
2024-08-13 16:23:20 -04:00
2024-07-22 22:51:53 +00:00
2024-07-11 12:23:44 +10:00
2024-07-11 12:23:44 +10:00
2024-07-23 01:48:03 +02:00
2024-07-26 14:41:56 -04:00
2024-08-12 12:54:18 -05:00
2024-07-14 13:50:09 +09:00
2024-08-07 20:43:05 -04:00
2024-07-23 01:26:25 +02:00
2024-07-22 22:51:53 +00:00
2024-07-24 16:00:48 +00:00
2024-07-15 22:05:45 +02:00
2024-08-10 16:23:55 +02:00
2024-07-11 20:39:24 +00:00
2024-07-22 22:51:53 +00:00
2024-07-22 22:51:53 +00:00
2024-07-29 23:49:51 +00:00
2024-03-20 17:29:58 +00:00
2024-08-10 12:07:17 +02:00
2024-04-24 22:21:15 +00:00
2024-07-26 14:41:56 -04:00
2024-07-23 00:29:39 -03:00
2024-07-29 23:49:51 +00:00
2024-07-04 06:06:33 +00:00
2024-07-25 20:53:33 +03:00
2024-03-24 09:34:11 +01:00
2024-06-03 07:25:32 +02:00
2024-06-19 13:54:55 +01:00
2024-05-21 20:16:39 +00:00
2024-07-26 14:41:56 -04:00
2024-07-18 00:00:04 +00:00
2024-05-09 14:47:09 +10:00
2024-03-22 11:27:34 -04:00
2024-08-05 09:55:14 -04:00
2024-06-19 04:41:56 +00:00
2024-07-02 11:37:59 -04:00
2024-06-13 12:55:55 +02:00
2024-03-27 14:02:16 +00:00
2024-07-04 02:02:21 +00:00
2024-07-04 02:02:21 +00:00
2024-04-17 13:00:43 +02:00
2024-07-26 14:41:56 -04:00
2024-07-26 14:41:56 -04:00
2024-06-25 10:00:30 +08:00
2024-07-04 05:36:34 +00:00
2024-07-04 02:02:21 +00:00
2024-07-22 22:51:53 +00:00
2024-07-11 12:23:44 +10:00
2024-06-11 15:47:00 +02:00
2024-04-07 01:16:45 +02:00
2024-02-29 14:43:43 +01:00
2024-02-29 14:43:43 +01:00
2024-03-12 10:59:41 +01:00
2024-03-07 06:27:09 +00:00
2024-04-07 01:16:45 +02:00
2024-03-03 18:53:35 +00:00
2024-05-28 12:31:33 +02:00
2024-03-06 12:35:07 -08:00
2024-07-25 20:53:33 +03:00
2024-07-06 21:00:30 +08:00
2024-07-06 21:00:30 +08:00
2024-06-25 10:00:30 +08:00
2024-07-02 11:37:59 -04:00
2024-04-07 01:16:45 +02:00
2024-04-15 08:54:11 -04:00
2024-04-15 08:54:11 -04:00
2024-07-14 13:50:09 +09:00
2024-04-11 16:41:42 +00:00
2024-03-11 09:36:35 -07:00
2024-08-03 20:09:42 -04:00
2024-08-03 20:09:42 -04:00
2024-03-11 09:36:35 -07:00
2024-07-22 22:51:53 +00:00
2024-08-06 04:08:10 +00:00
2024-06-25 18:06:22 +02:00
2024-03-11 09:36:35 -07:00
2024-03-07 14:26:31 +00:00
2024-07-12 21:16:09 -04:00
2024-07-02 15:48:48 -04:00
2024-04-17 13:00:43 +02:00
2024-04-17 13:00:43 +02:00
2024-07-11 12:23:44 +10:00
2024-07-05 00:52:01 +00:00
2024-06-29 19:39:09 +08:00
2024-05-20 11:13:10 -04:00
2024-04-24 08:05:29 +00:00
2024-05-11 15:13:18 +02:00