Files
rust/tests/ui
bors 59bb9505bc Auto merge of #103208 - cjgillot:match-fake-read, r=oli-obk,RalfJung
Allow partially moved values in match

This PR attempts to unify the behaviour between `let _ = PLACE`, `let _: TY = PLACE;` and `match PLACE { _ => {} }`.
The logical conclusion is that the `match` version should not check for uninitialised places nor check that borrows are still live.

The `match PLACE {}` case is handled by keeping a `FakeRead` in the unreachable fallback case to verify that `PLACE` has a legal value.

Schematically, `match PLACE { arms }` in surface rust becomes in MIR:
```rust
PlaceMention(PLACE)
match PLACE {
  // Decision tree for the explicit arms
  arms,
  // An extra fallback arm
  _ => {
    FakeRead(ForMatchedPlace, PLACE);
    unreachable
  }
}
```

`match *borrow { _ => {} }` continues to check that `*borrow` is live, but does not read the value.
`match *borrow {}` both checks that `*borrow` is live, and fake-reads the value.

Continuation of ~https://github.com/rust-lang/rust/pull/102256~ ~https://github.com/rust-lang/rust/pull/104844~

Fixes https://github.com/rust-lang/rust/issues/99180 https://github.com/rust-lang/rust/issues/53114
2023-10-27 18:51:43 +00:00
..
2023-10-17 17:33:55 +00:00
2023-10-24 15:30:17 +00:00
2023-10-08 10:06:17 +00:00
2023-10-05 01:04:41 +00:00
2023-10-20 21:14:01 +00:00
2023-10-04 08:01:11 +08:00
2023-10-08 10:06:17 +00:00
2023-05-30 13:03:40 +02:00
2023-10-20 21:14:02 +00:00
2023-10-04 08:01:11 +08:00
2023-07-17 22:06:32 +00:00
2023-10-20 21:14:01 +00:00
2023-09-06 12:09:29 +03:00
2023-10-08 10:06:17 +00:00
2023-10-16 16:29:35 +00:00
2023-10-20 21:14:01 +00:00
2023-10-08 10:06:17 +00:00
2023-10-11 04:55:55 +02:00
2023-10-17 17:33:55 +00:00
2023-08-28 17:47:37 -03:00
2023-10-20 21:14:01 +00:00
2023-04-29 13:01:46 +01:00
2023-07-29 11:47:26 +02:00
2023-10-11 04:55:55 +02:00
2023-10-20 21:14:01 +00:00
2023-04-03 09:24:11 +02:00
2023-08-14 16:57:51 -07:00
2023-10-02 23:14:29 +00:00
2023-10-17 17:33:55 +00:00
2023-03-29 18:04:44 -04:00
2023-09-18 17:29:13 +01:00
2023-10-20 21:14:01 +00:00
2023-10-05 01:04:41 +00:00
2023-10-20 21:14:01 +00:00
2023-04-29 13:01:46 +01:00
2023-10-05 01:04:41 +00:00
2023-04-13 22:10:26 -05:00
2023-04-13 22:10:26 -05:00
2023-09-10 23:06:14 +02:00
2023-09-10 23:06:14 +02:00
2023-10-20 21:14:01 +00:00