]> git.lizzy.rs Git - rust.git/commitdiff
[MIR] use mir::repr::Constant in ExprKind::Repeat, close #29789
authorFlorian Hahn <flo@fhahn.com>
Fri, 15 Jan 2016 21:44:53 +0000 (22:44 +0100)
committerFlorian Hahn <flo@fhahn.com>
Thu, 21 Jan 2016 21:46:50 +0000 (22:46 +0100)
src/librustc_mir/build/expr/as_rvalue.rs
src/librustc_mir/hair/cx/expr.rs
src/librustc_mir/hair/mod.rs

index 2f57dd22454cb50c3841216fe1512b27e86fd6df..c389e8e7330917f7d88dba8fce39998b93d1e2ac 100644 (file)
@@ -44,7 +44,6 @@ fn expr_as_rvalue(&mut self,
             }
             ExprKind::Repeat { value, count } => {
                 let value_operand = unpack!(block = this.as_operand(block, value));
-                let count = this.as_constant(count);
                 block.and(Rvalue::Repeat(value_operand, count))
             }
             ExprKind::Borrow { region, borrow_kind, arg } => {
index 57a43c3a180f2192f67a486ae35fc345e4294c3a..121b9c70ec35d4b917378b7321ccac327c91f75a 100644 (file)
@@ -325,14 +325,11 @@ fn make_mirror<'a>(self, cx: &mut Cx<'a, 'tcx>) -> Expr<'tcx> {
 
             hir::ExprRepeat(ref v, ref c) => ExprKind::Repeat {
                 value: v.to_ref(),
-                count: Expr {
+                count: Constant {
                     ty: cx.tcx.expr_ty(c),
-                    temp_lifetime: None,
                     span: c.span,
-                    kind: ExprKind::Literal {
-                        literal: cx.const_eval_literal(c)
-                    }
-                }.to_ref()
+                    literal: cx.const_eval_literal(c)
+                }
             },
             hir::ExprRet(ref v) =>
                 ExprKind::Return { value: v.to_ref() },
index fb81cc7e6d97a4394d65702fbf809466616046d0..0c673b4a644e68b47d7ab04ffc82d5a131e10c45 100644 (file)
@@ -14,7 +14,7 @@
 //! unit-tested and separated from the Rust source and compiler data
 //! structures.
 
-use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp, ItemKind};
+use rustc::mir::repr::{Constant, BinOp, BorrowKind, Field, Literal, Mutability, UnOp, ItemKind};
 use rustc::middle::const_eval::ConstVal;
 use rustc::middle::def_id::DefId;
 use rustc::middle::region::CodeExtent;
@@ -213,10 +213,7 @@ pub enum ExprKind<'tcx> {
     },
     Repeat {
         value: ExprRef<'tcx>,
-        // FIXME(#29789): Add a separate hair::Constant<'tcx> so this could be more explicit about
-        // its contained data. Currently this should only contain expression of ExprKind::Literal
-        // kind.
-        count: ExprRef<'tcx>,
+        count: Constant<'tcx>,
     },
     Vec {
         fields: Vec<ExprRef<'tcx>>,
@@ -341,7 +338,6 @@ pub struct FieldPattern<'tcx> {
     pub field: Field,
     pub pattern: Pattern<'tcx>,
 }
-
 ///////////////////////////////////////////////////////////////////////////
 // The Mirror trait