Files
rust/compiler
Jonathan Brouwer 94a62335e9 Rollup merge of #162785 - saethlin:match_branch_simplification, r=oli-obk
Avoid creating overlapping assignments in MatchBranchSimplification

MatchBranchSimplification can turn a match into an assignment, but doesn't make sure the LHS and RHS do not overlap. For example, the enum version of the mir-opt test in this PR is currently compiled with `-Zmir-opt-level=0 -Zmir-enable-passes=+MatchBranchSimplification` to
```
fn g(_1: Foo) -> Foo {
    let mut _0: Foo;
    let mut _2: Foo;
    let mut _3: *const Foo;
    let mut _4: u8;

    bb0: {
        _2 = copy _1;
        _3 = &raw const _2;
        _4 = discriminant((*_3));
        _2 = no_retag copy (*_3); // Since _3 = &raw const 2 above, this overlaps!
        _0 = copy _2;
        return;
    }
}
```
While this is technically a miscompile, I haven't found any way to turn this into something exciting, in part because the only thing that can be made to overlap here is a by-value enum discriminant which is always register-sized so backends lower this in a way that is okay with overlapping.
2026-09-17 16:50:52 +02:00
..
2026-09-15 23:07:25 +02:00
2026-09-17 06:52:28 +02:00
2026-09-17 06:52:28 +02:00