Change:
See and relevant FIXME in
As a side-note, would solve this problem quite neatly, if we were to adopt and implement it. :)

Discussion:
Use(Operand<'tcx>), // [x; 32] <del> Repeat(Operand<'tcx>, Constant<'tcx>), </del> <ins> Repeat(Operand<'tcx>, TypedConstVal<'tcx>), </ins> // &x or &mut x Ref(Region, BorrowKind, Lvalue<'tcx>),

pub literal: Literal<'tcx>, } <ins> #[derive(Clone, RustcEncodable, RustcDecodable)] pub struct TypedConstVal<'tcx> { pub ty: Ty<'tcx>, pub span: Span, pub value: ConstVal } impl<'tcx> Debug for TypedConstVal<'tcx> { fn fmt(&self, fmt: &mut Formatter) -> fmt::Result { try!(write!(fmt, "const ")); fmt_const_val(fmt, &self.value) } } </ins> #[derive(Clone, Copy, Debug, PartialEq, RustcEncodable, RustcDecodable)] pub enum ItemKind { Constant,

} Rvalue::Repeat(ref $($mutability)* value, <del> ref $($mutability)* len) => { </del> <ins> _) => { </ins> self.visit_operand(value); <del> self.visit_constant(len); </del> } Rvalue::Ref(r, bk, ref $($mutability)* path) => {

} ExprKind::Repeat { value, count } => { let value_operand = unpack!(block = this.as_operand(block, value)); <del> let count = this.as_constant(count); </del> block.and(Rvalue::Repeat(value_operand, count)) } ExprKind::Borrow { region, borrow_kind, arg } => {

use hair::cx::to_ref::ToRef; use rustc::front::map; use rustc::middle::def::Def; <ins> use rustc::middle::const_eval; </ins> use rustc::middle::region::CodeExtent; use rustc::middle::pat_util; use rustc::middle::ty::{self, VariantDef, Ty};

hir::ExprRepeat(ref v, ref c) => ExprKind::Repeat { value: v.to_ref(), <del> count: Expr { </del> <ins> count: TypedConstVal { </ins> ty: cx.tcx.expr_ty(c), <del> temp_lifetime: None, </del> span: c.span, <del> kind: ExprKind::Literal { literal: cx.const_eval_literal(c) } }.to_ref() </del> <ins> value: const_eval::eval_const_expr(cx.tcx, c) } </ins> }, hir::ExprRet(ref v) => ExprKind::Return { value: v.to_ref() },

//! unit-tested and separated from the Rust source and compiler data //! structures. <del> use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp, ItemKind}; </del> <ins> use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp, ItemKind, TypedConstVal}; </ins> use rustc::middle::const_eval::ConstVal; use rustc::middle::def_id::DefId; use rustc::middle::region::CodeExtent;

}, Repeat { value: ExprRef<'tcx>, <del> // 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>, </del> <ins> count: TypedConstVal<'tcx>, </ins> }, Vec { fields: Vec<ExprRef<'tcx>>,

Rvalue::Use(ref mut operand) => { self.erase_regions_operand(operand) } <del> Rvalue::Repeat(ref mut operand, ref mut constant) => { </del> <ins> Rvalue::Repeat(ref mut operand, ref mut value) => { </ins> self.erase_regions_operand(operand); <del> self.erase_regions_constant(constant); </del> <ins> value.ty = self.tcx.erase_regions(&value.ty); </ins> } Rvalue::Ref(ref mut region, _, ref mut lvalue) => { *region = ty::ReStatic;

mir::Rvalue::Repeat(ref elem, ref count) => { let elem = self.trans_operand(bcx, elem); <del> let size = self.trans_constant(bcx, count).immediate(); </del> <ins> let size = self.trans_constval(bcx, &count.value, count.ty).immediate(); </ins> let base = expr::get_dataptr(bcx, dest.llval); tvec::iter_vec_raw(bcx, base, elem.ty, size, |bcx, llslot, _| { self.store_operand(bcx, llslot, elem);