rust/tests/mir-opt/dataflow-const-prop
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
..
array_index.main.DataflowConstProp.32bit.panic-abort.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
array_index.main.DataflowConstProp.32bit.panic-unwind.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
array_index.main.DataflowConstProp.64bit.panic-abort.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
array_index.main.DataflowConstProp.64bit.panic-unwind.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
array_index.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
boolean_identities.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
boolean_identities.test.DataflowConstProp.diff Implement algebraic simplifications. 2023-09-06 15:57:50 +00:00
cast.main.DataflowConstProp.diff Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
cast.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
checked.main.DataflowConstProp.panic-abort.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
checked.main.DataflowConstProp.panic-unwind.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
checked.rs Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
default_boxed_slice.main.ConstProp.32bit.panic-abort.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
default_boxed_slice.main.ConstProp.32bit.panic-unwind.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
default_boxed_slice.main.ConstProp.64bit.panic-abort.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
default_boxed_slice.main.ConstProp.64bit.panic-unwind.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
default_boxed_slice.main.DataflowConstProp.32bit.panic-abort.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
default_boxed_slice.main.DataflowConstProp.32bit.panic-unwind.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
default_boxed_slice.main.DataflowConstProp.64bit.panic-abort.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
default_boxed_slice.main.DataflowConstProp.64bit.panic-unwind.diff Normalize alloc-id in tests. 2023-10-16 16:29:35 +00:00
default_boxed_slice.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
enum.constant.DataflowConstProp.32bit.diff Duplicate output for test. 2023-09-11 16:29:42 +00:00
enum.constant.DataflowConstProp.64bit.diff Duplicate output for test. 2023-09-11 16:29:42 +00:00
enum.multiple.DataflowConstProp.32bit.diff Duplicate output for test. 2023-09-11 16:29:42 +00:00
enum.multiple.DataflowConstProp.64bit.diff Duplicate output for test. 2023-09-11 16:29:42 +00:00
enum.mutate_discriminant.DataflowConstProp.32bit.diff Duplicate output for test. 2023-09-11 16:29:42 +00:00
enum.mutate_discriminant.DataflowConstProp.64bit.diff Duplicate output for test. 2023-09-11 16:29:42 +00:00
enum.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
enum.simple.DataflowConstProp.32bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
enum.simple.DataflowConstProp.64bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
enum.statics.DataflowConstProp.32bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
enum.statics.DataflowConstProp.64bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
if.main.DataflowConstProp.diff lower ExprKind::Use, LogicalOp::Or and UnOp::Not 2023-08-30 17:24:10 +08:00
if.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
inherit_overflow.main.DataflowConstProp.panic-abort.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
inherit_overflow.main.DataflowConstProp.panic-unwind.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
inherit_overflow.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
issue_81605.f.DataflowConstProp.diff Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
issue_81605.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
large_array_index.main.DataflowConstProp.32bit.panic-abort.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
large_array_index.main.DataflowConstProp.32bit.panic-unwind.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
large_array_index.main.DataflowConstProp.64bit.panic-abort.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
large_array_index.main.DataflowConstProp.64bit.panic-unwind.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
large_array_index.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
mult_by_zero.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
mult_by_zero.test.DataflowConstProp.diff Implement algebraic simplifications. 2023-09-06 15:57:50 +00:00
offset_of.concrete.DataflowConstProp.panic-abort.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
offset_of.concrete.DataflowConstProp.panic-unwind.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
offset_of.generic.DataflowConstProp.panic-abort.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
offset_of.generic.DataflowConstProp.panic-unwind.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
offset_of.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
ref_without_sb.main.DataflowConstProp.panic-abort.diff Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
ref_without_sb.main.DataflowConstProp.panic-unwind.diff Bless tests 2023-06-23 18:36:25 +01:00
ref_without_sb.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
repeat.main.DataflowConstProp.32bit.panic-abort.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
repeat.main.DataflowConstProp.32bit.panic-unwind.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
repeat.main.DataflowConstProp.64bit.panic-abort.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
repeat.main.DataflowConstProp.64bit.panic-unwind.diff Propagate PlaceElem::Index. 2023-09-06 16:09:31 +00:00
repeat.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
repr_transparent.main.DataflowConstProp.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
repr_transparent.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
self_assign.main.DataflowConstProp.diff Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
self_assign.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
self_assign_add.main.DataflowConstProp.diff Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
self_assign_add.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
sibling_ptr.main.DataflowConstProp.panic-abort.diff Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
sibling_ptr.main.DataflowConstProp.panic-unwind.diff Bless tests 2023-06-23 18:36:25 +01:00
sibling_ptr.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
slice_len.main.DataflowConstProp.32bit.panic-abort.diff Support non-scalar constants. 2023-09-11 16:29:41 +00:00
slice_len.main.DataflowConstProp.32bit.panic-unwind.diff Support non-scalar constants. 2023-09-11 16:29:41 +00:00
slice_len.main.DataflowConstProp.64bit.panic-abort.diff Support non-scalar constants. 2023-09-11 16:29:41 +00:00
slice_len.main.DataflowConstProp.64bit.panic-unwind.diff Support non-scalar constants. 2023-09-11 16:29:41 +00:00
slice_len.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
struct.main.DataflowConstProp.32bit.diff Tweak test to avoid platform dependency. 2023-10-24 15:16:57 +00:00
struct.main.DataflowConstProp.64bit.diff Tweak test to avoid platform dependency. 2023-10-24 15:16:57 +00:00
struct.rs Tweak test to avoid platform dependency. 2023-10-24 15:16:57 +00:00
terminator.main.DataflowConstProp.panic-abort.diff Remove comments from mir-opt MIR dumps 2023-06-15 15:19:11 -04:00
terminator.main.DataflowConstProp.panic-unwind.diff Bless tests 2023-06-23 18:36:25 +01:00
terminator.rs Allow to run filecheck in mir-opt tests. 2023-10-19 15:51:52 +00:00
transmute.from_char.DataflowConstProp.32bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.from_char.DataflowConstProp.64bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.invalid_bool.DataflowConstProp.32bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.invalid_bool.DataflowConstProp.64bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.invalid_char.DataflowConstProp.32bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.invalid_char.DataflowConstProp.64bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.less_as_i8.DataflowConstProp.32bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.less_as_i8.DataflowConstProp.64bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.rs Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
transmute.undef_union_as_integer.DataflowConstProp.32bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
transmute.undef_union_as_integer.DataflowConstProp.64bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
transmute.unreachable_box.DataflowConstProp.32bit.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
transmute.unreachable_box.DataflowConstProp.64bit.diff Use PlaceMention for match scrutinees. 2023-10-24 15:30:17 +00:00
transmute.unreachable_direct.DataflowConstProp.32bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
transmute.unreachable_direct.DataflowConstProp.64bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
transmute.unreachable_mut.DataflowConstProp.32bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.unreachable_mut.DataflowConstProp.64bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.unreachable_ref.DataflowConstProp.32bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.unreachable_ref.DataflowConstProp.64bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.valid_char.DataflowConstProp.32bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
transmute.valid_char.DataflowConstProp.64bit.diff Support a few more rvalues. 2023-09-06 15:52:06 +00:00
tuple.main.DataflowConstProp.32bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
tuple.main.DataflowConstProp.64bit.diff Use a ConstValue instead. 2023-10-21 16:26:05 +00:00
tuple.rs Use a ConstValue instead. 2023-10-21 16:26:05 +00:00