Skip to content

Commit 982726c

Browse files
committed
Consider CopyForDeref for DestProp.
1 parent 8f7e441 commit 982726c

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

compiler/rustc_mir_transform/src/dest_prop.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -328,7 +328,8 @@ impl<'a, 'tcx> MutVisitor<'tcx> for Merger<'a, 'tcx> {
328328
match &statement.kind {
329329
StatementKind::Assign(box (dest, rvalue)) => {
330330
match rvalue {
331-
Rvalue::Use(Operand::Copy(place) | Operand::Move(place)) => {
331+
Rvalue::CopyForDeref(place)
332+
| Rvalue::Use(Operand::Copy(place) | Operand::Move(place)) => {
332333
// These might've been turned into self-assignments by the replacement
333334
// (this includes the original statement we wanted to eliminate).
334335
if dest == place {
@@ -754,7 +755,7 @@ impl<'tcx> Visitor<'tcx> for FindAssignments<'_, '_, 'tcx> {
754755
fn visit_statement(&mut self, statement: &Statement<'tcx>, _: Location) {
755756
if let StatementKind::Assign(box (
756757
lhs,
757-
Rvalue::Use(Operand::Copy(rhs) | Operand::Move(rhs)),
758+
Rvalue::CopyForDeref(rhs) | Rvalue::Use(Operand::Copy(rhs) | Operand::Move(rhs)),
758759
)) = &statement.kind
759760
{
760761
let Some((src, dest)) = places_to_candidate_pair(*lhs, *rhs, self.body) else {

0 commit comments

Comments
 (0)