mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 00:03:43 +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 |
||
---|---|---|
.. | ||
rfc-0107-bind-by-move-pattern-guards | ||
rfc-1014-stdout-existential-crisis | ||
rfc-1445-restrict-constants-in-patterns | ||
rfc-1623-static | ||
rfc-1717-dllimport | ||
rfc-1789-as-cell | ||
rfc-1857-stabilize-drop-order | ||
rfc-1937-termination-trait | ||
rfc-2005-default-binding-mode | ||
rfc-2008-non-exhaustive | ||
rfc-2027-object-safe-for-dispatch | ||
rfc-2091-track-caller | ||
rfc-2093-infer-outlives | ||
rfc-2126-crate-paths | ||
rfc-2126-extern-absolute-paths | ||
rfc-2151-raw-identifiers | ||
rfc-2175-or-if-while-let | ||
rfc-2294-if-let-guard | ||
rfc-2302-self-struct-ctor | ||
rfc-2306-convert-id | ||
rfc-2361-dbg-macro | ||
rfc-2396-target_feature-11 | ||
rfc-2397-do-not-recommend | ||
rfc-2421-unreserve-pure-offsetof-sizeof-alignof | ||
rfc-2457-non-ascii-idents | ||
rfc-2497-if-let-chains | ||
rfc-2528-type-changing-struct-update | ||
rfc-2565-param-attrs | ||
rfc-2627-raw-dylib | ||
rfc-2632-const-trait-impl | ||
rfc-3348-c-string-literals |