Matthias Krüger
7fb36f2d3b
Rollup merge of #120214 - Nadrieril:fix-120210, r=pnkfelix
...
match lowering: consistently lower bindings deepest-first
Currently when lowering match expressions to MIR, we do a funny little dance with the order of bindings. I attempt to explain it in the third commit: we handle refutable (i.e. needing a test) patterns differently than irrefutable ones. This leads to inconsistencies, as reported in https://github.com/rust-lang/rust/issues/120210 . The reason we need a dance at all is for situations like:
```rust
fn foo1(x: NonCopyStruct) {
let y @ NonCopyStruct { copy_field: z } = x;
// the above should turn into
let z = x.copy_field;
let y = x;
}
```
Here the `y ```````@```````` binding will move out of `x`, so we need to copy the field first.
I believe that the inconsistency came about when we fixed https://github.com/rust-lang/rust/issues/69971 , and didn't notice that the fix didn't extend to refutable patterns. My guess then is that ordering bindings by "deepest-first, otherwise source order" is a sound choice. This PR implements that (at least I hope, match lowering is hard to follow 🥲 ).
Fixes https://github.com/rust-lang/rust/issues/120210
r? ```````@oli-obk``````` since you merged the original fix to https://github.com/rust-lang/rust/issues/69971
cc ```````@matthewjasper```````
2024-02-08 09:06:33 +01:00
..
2024-01-30 15:46:40 +00:00
2024-01-02 15:34:37 -05:00
2023-12-21 16:45:29 +05:30
2024-02-07 10:42:01 +08:00
2024-01-26 17:25:02 +01:00
2024-01-30 03:33:12 +00:00
2024-02-08 05:01:09 +00:00
2024-01-26 20:47:11 +00:00
2023-11-30 20:59:51 +01:00
2024-02-07 10:42:01 +08:00
2024-02-07 10:42:01 +08:00
2024-02-08 09:06:32 +01:00
2023-12-12 15:54:25 +11:00
2024-02-07 10:42:01 +08:00
2024-01-02 15:34:37 -05:00
2024-02-07 18:24:43 +01:00
2024-01-30 21:28:18 +00:00
2024-01-30 21:28:18 +00:00
2024-01-16 09:25:28 +01:00
2024-01-30 19:26:13 +00:00
2024-02-07 10:42:01 +08:00
2024-01-13 20:06:03 +00:00
2024-02-07 10:42:01 +08:00
2024-01-13 22:05:46 +00:00
2024-02-06 22:45:41 +01:00
2024-01-24 02:53:15 +00:00
2024-02-06 22:45:41 +01:00
2024-01-13 12:46:58 -05:00
2024-01-27 12:19:41 +00:00
2024-02-07 10:42:01 +08:00
2024-02-08 05:01:09 +00:00
2023-12-14 15:22:37 +01:00
2024-01-24 17:23:42 +03:00
2024-01-13 12:46:58 -05:00
2023-11-28 23:17:28 +00:00
2024-02-07 10:42:01 +08:00
2023-12-07 17:46:36 +01:00
2024-02-07 10:42:01 +08:00
2024-02-07 16:18:31 +00:00
2024-02-07 10:42:01 +08:00
2023-11-28 15:39:31 +03:00
2024-01-12 13:59:47 -08:00
2024-02-06 22:45:42 +01:00
2024-02-07 10:42:01 +08:00
2024-01-09 19:25:54 +00:00
2024-01-13 12:46:58 -05:00
2023-12-21 16:45:29 +05:30
2024-01-30 16:57:47 +01:00
2024-02-07 10:42:01 +08:00
2024-01-02 15:34:37 -05:00
2024-02-01 03:31:03 +00:00
2024-01-09 21:08:16 +00:00
2024-01-24 16:32:24 +00:00
2024-02-07 10:42:01 +08:00
2024-01-05 19:13:52 +03:00
2023-12-23 00:09:37 +08:00
2024-02-01 16:18:03 +01:00
2024-02-01 16:18:03 +01:00
2024-02-08 05:01:09 +00:00
2023-12-09 08:53:20 -05:00
2024-01-30 21:28:18 +00:00
2024-02-07 10:42:01 +08:00
2024-01-13 12:46:58 -05:00
2024-01-29 17:43:07 +08:00
2024-02-07 10:42:01 +08:00
2024-02-06 17:44:53 +03:00
2024-02-06 22:45:42 +01:00
2024-01-30 21:28:18 +00:00
2024-01-09 21:08:16 +00:00
2024-01-30 21:28:18 +00:00
2024-01-23 10:31:07 +01:00
2024-01-30 21:28:18 +00:00
2024-02-07 10:42:01 +08:00
2024-01-31 16:51:42 +00:00
2024-02-07 10:42:01 +08:00
2024-02-05 11:07:26 +01:00
2024-02-06 22:45:42 +01:00
2024-01-11 21:39:44 +08:00
2024-01-07 17:29:25 +03:00
2024-02-07 10:42:01 +08:00
2024-01-19 15:27:32 +01:00
2024-01-31 08:25:29 +11:00
2024-01-30 21:28:18 +00:00
2024-01-31 16:51:42 +00:00
2023-12-11 09:36:40 +11:00
2024-02-01 10:27:54 +00:00
2024-01-30 21:28:18 +00:00
2024-01-26 14:43:29 +01:00
2024-01-13 12:46:58 -05:00
2023-12-08 00:00:00 +00:00
2024-02-08 05:01:09 +00:00
2024-02-01 03:30:26 +00:00
2024-01-30 21:28:18 +00:00
2024-02-04 19:42:12 +01:00
2024-01-27 16:38:57 +01:00
2024-02-01 16:18:03 +01:00
2023-12-07 23:00:46 -05:00
2024-01-23 21:16:24 +08:00
2024-02-01 16:18:03 +01:00
2024-01-13 12:46:58 -05:00
2024-02-07 18:24:42 +01:00
2024-01-05 09:30:27 +00:00
2023-12-07 23:00:46 -05:00
2024-02-07 10:42:01 +08:00
2024-02-01 03:31:03 +00:00
2024-02-05 10:17:31 +00:00
2024-02-05 11:07:26 +01:00
2024-02-07 10:42:01 +08:00
2024-02-07 10:42:01 +08:00
2024-01-30 16:57:47 +01:00
2023-12-27 17:26:12 +00:00
2024-01-30 21:28:18 +00:00
2024-02-07 10:42:01 +08:00
2024-01-30 21:28:18 +00:00
2023-11-30 08:26:13 -08:00
2024-02-01 20:01:05 +01:00
2024-01-09 13:23:15 +01:00
2024-01-10 21:18:54 +01:00
2024-01-30 21:28:18 +00:00
2024-01-27 16:38:57 +01:00
2024-01-09 21:08:16 +00:00
2024-02-07 10:42:01 +08:00
2024-01-30 21:28:18 +00:00
2024-01-30 21:28:18 +00:00
2024-01-18 17:29:54 +01:00
2024-02-07 10:42:01 +08:00
2024-01-18 13:16:09 -05:00
2024-01-29 19:48:44 +00:00
2024-01-13 12:46:58 -05:00
2024-01-11 16:55:10 +11:00
2024-02-07 15:26:57 +08:00
2024-02-07 10:42:01 +08:00
2024-02-08 09:06:33 +01:00
2024-01-16 14:58:42 -05:00
2024-02-07 16:01:58 +01:00
2024-02-07 10:42:01 +08:00
2024-02-07 10:42:01 +08:00
2024-01-05 09:30:27 +00:00
2024-01-02 15:34:37 -05:00
2024-02-01 03:30:26 +00:00
2024-01-13 12:46:58 -05:00
2024-01-30 21:28:18 +00:00
2024-01-02 15:34:37 -05:00
2024-02-07 10:42:01 +08:00
2024-01-24 00:41:45 +01:00
2024-01-13 12:46:58 -05:00
2024-01-29 17:43:07 +08:00
2024-02-07 10:42:01 +08:00
2024-02-07 10:42:01 +08:00
2024-01-05 09:30:27 +00:00
2024-02-07 10:42:01 +08:00
2024-01-13 12:46:58 -05:00
2024-01-03 10:00:15 -08:00
2024-02-01 16:18:03 +01:00
2024-01-08 15:25:55 -05:00
2024-01-05 09:30:27 +00:00
2024-01-20 02:30:58 +04:00
2024-02-07 10:42:01 +08:00
2024-02-06 02:22:57 +00:00
2024-02-08 05:01:09 +00:00
2024-01-13 12:46:58 -05:00
2023-12-14 18:10:38 +03:00
2024-01-07 17:29:25 +03:00
2024-02-07 10:42:01 +08:00
2024-01-31 16:59:19 +00:00
2024-02-07 10:42:01 +08:00
2024-02-01 03:31:03 +00:00
2024-02-07 10:42:01 +08:00
2024-02-08 05:01:09 +00:00
2024-01-26 12:39:03 +08:00
2024-02-06 02:22:58 +00:00
2024-01-30 21:28:18 +00:00
2024-01-13 12:46:58 -05:00
2024-02-01 16:51:07 -08:00
2023-12-30 18:17:28 +01:00
2024-01-13 12:46:58 -05:00
2024-02-07 10:42:01 +08:00
2024-01-13 12:46:58 -05:00
2024-01-13 12:46:58 -05:00
2024-02-01 03:31:03 +00:00
2024-02-08 05:01:09 +00:00
2024-01-24 02:53:15 +00:00
2024-01-25 16:23:53 +00:00
2024-02-01 10:36:34 -08:00
2024-01-30 21:28:18 +00:00
2024-01-30 21:28:18 +00:00
2024-01-19 11:32:34 +00:00
2024-02-07 10:42:01 +08:00
2023-12-01 17:25:02 +00:00
2024-02-05 10:17:31 +00:00
2024-02-04 11:34:10 +08:00
2024-01-13 12:46:58 -05:00
2024-02-07 10:42:01 +08:00
2023-12-09 00:44:49 +01:00
2024-02-05 11:07:26 +01:00
2024-01-13 12:46:58 -05:00
2023-12-26 04:07:38 +00:00
2024-02-01 10:27:54 +00:00
2024-02-01 03:31:03 +00:00
2024-01-30 21:28:18 +00:00
2024-01-07 20:48:31 +01:00
2024-02-01 16:18:03 +01:00
2024-02-01 03:31:03 +00:00
2024-02-07 10:42:01 +08:00
2023-12-10 10:56:22 +08:00
2024-01-24 02:53:15 +00:00
2023-12-10 10:56:22 +08:00
2023-12-21 10:17:11 +08:00
2024-01-13 12:46:58 -05:00
2023-12-10 10:56:22 +08:00
2023-12-10 10:56:22 +08:00
2024-02-07 10:42:01 +08:00
2024-01-02 15:34:37 -05:00
2024-01-02 15:34:37 -05:00
2023-12-15 16:12:27 +00:00
2024-02-07 10:42:01 +08:00
2024-02-07 10:42:01 +08:00
2024-01-13 12:46:58 -05:00
2023-12-12 17:40:53 +01:00
2024-02-06 22:45:39 +01:00
2024-01-30 21:28:18 +00:00
2024-01-23 10:31:07 +01:00
2024-01-02 15:34:37 -05:00
2024-01-30 21:28:18 +00:00
2024-01-30 21:28:18 +00:00
2024-01-30 21:28:18 +00:00
2024-01-30 21:28:18 +00:00
2024-01-02 15:34:37 -05:00
2024-01-02 15:34:37 -05:00
2024-01-02 15:34:37 -05:00
2023-12-16 19:56:50 -08:00
2024-01-02 15:34:37 -05:00
2024-01-13 12:46:58 -05:00
2024-01-02 15:34:37 -05:00
2024-01-09 21:08:16 +00:00
2024-02-01 16:18:03 +01:00
2023-12-10 13:03:28 -08:00
2024-01-02 15:34:37 -05:00
2024-02-07 10:42:01 +08:00
2024-02-07 10:42:01 +08:00
2024-01-21 13:47:45 +01:00