diff options
| author | bors <bors@rust-lang.org> | 2023-10-27 18:51:43 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2023-10-27 18:51:43 +0000 |
| commit | 59bb9505bc0d0c9fbf9b5daf052bf033b63e5cc0 (patch) | |
| tree | a3d662922a04455e5722399fcf049c9db4a54831 /compiler/rustc_interface/src | |
| parent | 10143e781b3ae63240b96cabe13cc33671ccb13a (diff) | |
| parent | 479fb4beb62788d904ec4cd50c79b858f54b662b (diff) | |
| download | rust-59bb9505bc0d0c9fbf9b5daf052bf033b63e5cc0.tar.gz rust-59bb9505bc0d0c9fbf9b5daf052bf033b63e5cc0.zip | |
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
Diffstat (limited to 'compiler/rustc_interface/src')
0 files changed, 0 insertions, 0 deletions
