]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/transform/copy_prop.rs
MIR: split Operand::Consume into Copy and Move.
[rust.git] / src / librustc_mir / transform / copy_prop.rs
index 2966290c2964c145ec98da79b5c3359b14cf6e00..30048639589ffaa11c6814e6827de838a5e84066 100644 (file)
@@ -126,7 +126,8 @@ fn run_pass<'a, 'tcx>(&self,
                         StatementKind::Assign(Lvalue::Local(local), Rvalue::Use(ref operand)) if
                                 local == dest_local => {
                             let maybe_action = match *operand {
-                                Operand::Consume(ref src_lvalue) => {
+                                Operand::Copy(ref src_lvalue) |
+                                Operand::Move(ref src_lvalue) => {
                                     Action::local_copy(&mir, &def_use_analysis, src_lvalue)
                                 }
                                 Operand::Constant(ref src_constant) => {
@@ -173,7 +174,11 @@ fn eliminate_self_assignments<'tcx>(
                 match stmt.kind {
                     StatementKind::Assign(
                         Lvalue::Local(local),
-                        Rvalue::Use(Operand::Consume(Lvalue::Local(src_local))),
+                        Rvalue::Use(Operand::Copy(Lvalue::Local(src_local))),
+                    ) |
+                    StatementKind::Assign(
+                        Lvalue::Local(local),
+                        Rvalue::Use(Operand::Move(Lvalue::Local(src_local))),
                     ) if local == dest_local && dest_local == src_local => {}
                     _ => {
                         continue;
@@ -351,7 +356,8 @@ fn visit_operand(&mut self, operand: &mut Operand<'tcx>, location: Location) {
         self.super_operand(operand, location);
 
         match *operand {
-            Operand::Consume(Lvalue::Local(local)) if local == self.dest_local => {}
+            Operand::Copy(Lvalue::Local(local)) |
+            Operand::Move(Lvalue::Local(local)) if local == self.dest_local => {}
             _ => return,
         }