Skip to content

Commit d58061e

Browse files
committed
Restrict simple assignment condition.
1 parent 8811344 commit d58061e

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

compiler/rustc_mir_transform/src/dest_prop.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,14 @@ fn save_as_intervals<'tcx>(
596596
// as behaving so by default.
597597
// We make an exception for simple assignments `_a.stuff = {copy|move} _b.stuff`,
598598
// as marking `_b` live here would prevent unification.
599-
let is_simple_assignment =
600-
matches!(stmt.kind, StatementKind::Assign(box (_, Rvalue::Use(_))));
599+
let is_simple_assignment = match stmt.kind {
600+
StatementKind::Assign(box (
601+
lhs,
602+
Rvalue::CopyForDeref(rhs)
603+
| Rvalue::Use(Operand::Copy(rhs) | Operand::Move(rhs)),
604+
)) => lhs.projection == rhs.projection,
605+
_ => false,
606+
};
601607
VisitPlacesWith(|place: Place<'tcx>, ctxt| {
602608
if let Some(relevant) = relevant.shrink[place.local] {
603609
match DefUse::for_place(place, ctxt) {

0 commit comments

Comments
 (0)