]> git.lizzy.rs Git - rust.git/blobdiff - src/librustc_mir/build/expr/as_rvalue.rs
MIR: split Operand::Consume into Copy and Move.
[rust.git] / src / librustc_mir / build / expr / as_rvalue.rs
index d17f00b489c318bb4a6bd3c99510983e374d0217..b6f2477a930122a0ab7ac334f53804cdb2b77a21 100644 (file)
@@ -90,7 +90,7 @@ fn expr_as_rvalue(&mut self,
                                          Rvalue::BinaryOp(BinOp::Eq, arg.clone(), minval));
 
                     let err = ConstMathErr::Overflow(Op::Neg);
-                    block = this.assert(block, Operand::Consume(is_min), false,
+                    block = this.assert(block, Operand::Move(is_min), false,
                                         AssertMessage::Math(err), expr_span);
                 }
                 block.and(Rvalue::UnaryOp(op, arg))
@@ -117,7 +117,7 @@ fn expr_as_rvalue(&mut self,
 
                 // initialize the box contents:
                 unpack!(block = this.into(&Lvalue::Local(result).deref(), block, value));
-                block.and(Rvalue::Use(Operand::Consume(Lvalue::Local(result))))
+                block.and(Rvalue::Use(Operand::Move(Lvalue::Local(result))))
             }
             ExprKind::Cast { source } => {
                 let source = this.hir.mirror(source);
@@ -238,7 +238,7 @@ fn expr_as_rvalue(&mut self,
                         .zip(field_types.into_iter())
                         .map(|(n, ty)| match fields_map.get(&n) {
                             Some(v) => v.clone(),
-                            None => Operand::Consume(base.clone().field(n, ty))
+                            None => this.consume_by_copy_or_move(base.clone().field(n, ty))
                         })
                         .collect()
                 } else {
@@ -325,10 +325,10 @@ pub fn build_binary_op(&mut self, mut block: BasicBlock,
                 }
             });
 
-            block = self.assert(block, Operand::Consume(of), false,
+            block = self.assert(block, Operand::Move(of), false,
                                 AssertMessage::Math(err), span);
 
-            block.and(Rvalue::Use(Operand::Consume(val)))
+            block.and(Rvalue::Use(Operand::Move(val)))
         } else {
             if ty.is_integral() && (op == BinOp::Div || op == BinOp::Rem) {
                 // Checking division and remainder is more complex, since we 1. always check
@@ -348,7 +348,7 @@ pub fn build_binary_op(&mut self, mut block: BasicBlock,
                 self.cfg.push_assign(block, source_info, &is_zero,
                                      Rvalue::BinaryOp(BinOp::Eq, rhs.clone(), zero));
 
-                block = self.assert(block, Operand::Consume(is_zero), false,
+                block = self.assert(block, Operand::Move(is_zero), false,
                                     AssertMessage::Math(zero_err), span);
 
                 // We only need to check for the overflow in one case:
@@ -368,12 +368,12 @@ pub fn build_binary_op(&mut self, mut block: BasicBlock,
                     self.cfg.push_assign(block, source_info, &is_min,
                                          Rvalue::BinaryOp(BinOp::Eq, lhs.clone(), min));
 
-                    let is_neg_1 = Operand::Consume(is_neg_1);
-                    let is_min = Operand::Consume(is_min);
+                    let is_neg_1 = Operand::Move(is_neg_1);
+                    let is_min = Operand::Move(is_min);
                     self.cfg.push_assign(block, source_info, &of,
                                          Rvalue::BinaryOp(BinOp::BitAnd, is_neg_1, is_min));
 
-                    block = self.assert(block, Operand::Consume(of), false,
+                    block = self.assert(block, Operand::Move(of), false,
                                         AssertMessage::Math(overflow_err), span);
                 }
             }