mirror of
https://github.com/rust-lang/rust.git
synced 2024-10-31 14:31:55 +00:00
59bb9505bc
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 |
||
---|---|---|
.. | ||
auxiliary | ||
abi-mismatch.rs | ||
abi-mismatch.stderr | ||
assoc_const_2.rs | ||
assoc_const_2.stderr | ||
assoc_const.rs | ||
assoc_const.stderr | ||
box.rs | ||
box.stderr | ||
const_refers_to_static_cross_crate.32bit.stderr | ||
const_refers_to_static_cross_crate.64bit.stderr | ||
const_refers_to_static_cross_crate.rs | ||
const_refers_to_static.32bit.stderr | ||
const_refers_to_static.64bit.stderr | ||
const_refers_to_static.rs | ||
drop.rs | ||
drop.stderr | ||
feature-gate-unleash_the_miri_inside_of_you.rs | ||
feature-gate-unleash_the_miri_inside_of_you.stderr | ||
inline_asm.rs | ||
inline_asm.stderr | ||
mutable_references_err.32bit.stderr | ||
mutable_references_err.64bit.stderr | ||
mutable_references_err.rs | ||
mutable_references.rs | ||
mutable_references.stderr | ||
mutating_global.rs | ||
mutating_global.stderr | ||
non_const_fn.rs | ||
non_const_fn.stderr | ||
ptr_arith.rs | ||
ptr_arith.stderr | ||
raw_mutable_const.rs | ||
raw_mutable_const.stderr | ||
slice_eq.rs | ||
tls.rs | ||
tls.stderr |