Skip to content

Commit

Permalink
[MIR] use mir::repr::Constant in ExprKind::Repeat, close #29789
Browse files Browse the repository at this point in the history
  • Loading branch information
fhahn committed Jan 21, 2016
1 parent 9ae76b3 commit c786091
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 13 deletions.
1 change: 0 additions & 1 deletion src/librustc_mir/build/expr/as_rvalue.rs
Expand Up @@ -44,7 +44,6 @@ impl<'a,'tcx> Builder<'a,'tcx> {
}
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 } => {
Expand Down
9 changes: 3 additions & 6 deletions src/librustc_mir/hair/cx/expr.rs
Expand Up @@ -325,14 +325,11 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {

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() },
Expand Down
8 changes: 2 additions & 6 deletions src/librustc_mir/hair/mod.rs
Expand Up @@ -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;
Expand Down Expand Up @@ -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>>,
Expand Down Expand Up @@ -341,7 +338,6 @@ pub struct FieldPattern<'tcx> {
pub field: Field,
pub pattern: Pattern<'tcx>,
}

///////////////////////////////////////////////////////////////////////////
// The Mirror trait

Expand Down

0 comments on commit c786091

Please sign in to comment.