提交 c7860913 编写于 作者: F Florian Hahn

[MIR] use mir::repr::Constant in ExprKind::Repeat, close #29789

上级 9ae76b36
......@@ -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 } => {
......
......@@ -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() },
......
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册