]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/build/matches/test.rs
MIR: split Operand::Consume into Copy and Move.
[rust.git] / src / librustc_mir / build / matches / test.rs
index 02a7bc83f6ee822cece374180c16a62a9ea554c9..b3a46508cf0b232bc641c20806085c4f534ab651 100644 (file)
@@ -215,7 +215,7 @@ pub fn perform_test(&mut self,
                                      Rvalue::Discriminant(lvalue.clone()));
                 assert_eq!(values.len() + 1, targets.len());
                 self.cfg.terminate(block, source_info, TerminatorKind::SwitchInt {
-                    discr: Operand::Consume(discr),
+                    discr: Operand::Move(discr),
                     switch_ty: discr_ty,
                     values: From::from(values),
                     targets,
@@ -233,7 +233,7 @@ pub fn perform_test(&mut self,
                         ConstVal::Bool(false) => vec![false_bb, true_bb],
                         v => span_bug!(test.span, "expected boolean value but got {:?}", v)
                     };
-                    (ret, TerminatorKind::if_(self.hir.tcx(), Operand::Consume(lvalue.clone()),
+                    (ret, TerminatorKind::if_(self.hir.tcx(), Operand::Copy(lvalue.clone()),
                                               true_bb, false_bb))
                 } else {
                     // The switch may be inexhaustive so we
@@ -248,7 +248,7 @@ pub fn perform_test(&mut self,
                         v.val.to_const_int().expect("switching on integral")
                     ).collect();
                     (targets.clone(), TerminatorKind::SwitchInt {
-                        discr: Operand::Consume(lvalue.clone()),
+                        discr: Operand::Copy(lvalue.clone()),
                         switch_ty,
                         values: From::from(values),
                         targets,
@@ -259,7 +259,7 @@ pub fn perform_test(&mut self,
             }
 
             TestKind::Eq { value, mut ty } => {
-                let mut val = Operand::Consume(lvalue.clone());
+                let mut val = Operand::Copy(lvalue.clone());
 
                 // If we're using b"..." as a pattern, we need to insert an
                 // unsizing coercion, as the byte string has the type &[u8; N].
@@ -273,7 +273,7 @@ pub fn perform_test(&mut self,
                             let val_slice = self.temp(ty, test.span);
                             self.cfg.push_assign(block, source_info, &val_slice,
                                                  Rvalue::Cast(CastKind::Unsize, val, ty));
-                            val = Operand::Consume(val_slice);
+                            val = Operand::Move(val_slice);
                         }
                     }
 
@@ -288,7 +288,7 @@ pub fn perform_test(&mut self,
                     let slice = self.temp(ty, test.span);
                     self.cfg.push_assign(block, source_info, &slice,
                                          Rvalue::Cast(CastKind::Unsize, array, ty));
-                    Operand::Consume(slice)
+                    Operand::Move(slice)
                 } else {
                     self.literal_operand(test.span, ty, Literal::Value {
                         value
@@ -322,7 +322,7 @@ pub fn perform_test(&mut self,
                     let block = self.cfg.start_new_block();
                     self.cfg.terminate(eq_block, source_info,
                                        TerminatorKind::if_(self.hir.tcx(),
-                                                           Operand::Consume(eq_result),
+                                                           Operand::Move(eq_result),
                                                            block, fail));
                     vec![block, fail]
                 } else {
@@ -335,7 +335,7 @@ pub fn perform_test(&mut self,
                 // Test `val` by computing `lo <= val && val <= hi`, using primitive comparisons.
                 let lo = self.literal_operand(test.span, ty.clone(), lo.clone());
                 let hi = self.literal_operand(test.span, ty.clone(), hi.clone());
-                let val = Operand::Consume(lvalue.clone());
+                let val = Operand::Copy(lvalue.clone());
 
                 let fail = self.cfg.start_new_block();
                 let block = self.compare(block, fail, test.span, BinOp::Le, lo, val.clone());
@@ -362,14 +362,14 @@ pub fn perform_test(&mut self,
                 // result = actual == expected OR result = actual < expected
                 self.cfg.push_assign(block, source_info, &result,
                                      Rvalue::BinaryOp(op,
-                                                      Operand::Consume(actual),
-                                                      Operand::Consume(expected)));
+                                                      Operand::Move(actual),
+                                                      Operand::Move(expected)));
 
                 // branch based on result
                 let (false_bb, true_bb) = (self.cfg.start_new_block(),
                                            self.cfg.start_new_block());
                 self.cfg.terminate(block, source_info,
-                                   TerminatorKind::if_(self.hir.tcx(), Operand::Consume(result),
+                                   TerminatorKind::if_(self.hir.tcx(), Operand::Move(result),
                                                        true_bb, false_bb));
                 vec![true_bb, false_bb]
             }
@@ -394,7 +394,7 @@ fn compare(&mut self,
         // branch based on result
         let target_block = self.cfg.start_new_block();
         self.cfg.terminate(block, source_info,
-                           TerminatorKind::if_(self.hir.tcx(), Operand::Consume(result),
+                           TerminatorKind::if_(self.hir.tcx(), Operand::Move(result),
                                                target_block, fail_block));
         target_block
     }