Skip to content

Commit c786091

Browse files
committed
[MIR] use mir::repr::Constant in ExprKind::Repeat, close #29789
1 parent 9ae76b3 commit c786091

File tree

3 files changed

+5
-13
lines changed

3 files changed

+5
-13
lines changed

src/librustc_mir/build/expr/as_rvalue.rs

-1
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ impl<'a,'tcx> Builder<'a,'tcx> {
4444
}
4545
ExprKind::Repeat { value, count } => {
4646
let value_operand = unpack!(block = this.as_operand(block, value));
47-
let count = this.as_constant(count);
4847
block.and(Rvalue::Repeat(value_operand, count))
4948
}
5049
ExprKind::Borrow { region, borrow_kind, arg } => {

src/librustc_mir/hair/cx/expr.rs

+3-6
Original file line numberDiff line numberDiff line change
@@ -325,14 +325,11 @@ impl<'tcx> Mirror<'tcx> for &'tcx hir::Expr {
325325

326326
hir::ExprRepeat(ref v, ref c) => ExprKind::Repeat {
327327
value: v.to_ref(),
328-
count: Expr {
328+
count: Constant {
329329
ty: cx.tcx.expr_ty(c),
330-
temp_lifetime: None,
331330
span: c.span,
332-
kind: ExprKind::Literal {
333-
literal: cx.const_eval_literal(c)
334-
}
335-
}.to_ref()
331+
literal: cx.const_eval_literal(c)
332+
}
336333
},
337334
hir::ExprRet(ref v) =>
338335
ExprKind::Return { value: v.to_ref() },

src/librustc_mir/hair/mod.rs

+2-6
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
//! unit-tested and separated from the Rust source and compiler data
1515
//! structures.
1616
17-
use rustc::mir::repr::{BinOp, BorrowKind, Field, Literal, Mutability, UnOp, ItemKind};
17+
use rustc::mir::repr::{Constant, BinOp, BorrowKind, Field, Literal, Mutability, UnOp, ItemKind};
1818
use rustc::middle::const_eval::ConstVal;
1919
use rustc::middle::def_id::DefId;
2020
use rustc::middle::region::CodeExtent;
@@ -213,10 +213,7 @@ pub enum ExprKind<'tcx> {
213213
},
214214
Repeat {
215215
value: ExprRef<'tcx>,
216-
// FIXME(#29789): Add a separate hair::Constant<'tcx> so this could be more explicit about
217-
// its contained data. Currently this should only contain expression of ExprKind::Literal
218-
// kind.
219-
count: ExprRef<'tcx>,
216+
count: Constant<'tcx>,
220217
},
221218
Vec {
222219
fields: Vec<ExprRef<'tcx>>,
@@ -341,7 +338,6 @@ pub struct FieldPattern<'tcx> {
341338
pub field: Field,
342339
pub pattern: Pattern<'tcx>,
343340
}
344-
345341
///////////////////////////////////////////////////////////////////////////
346342
// The Mirror trait
347343

0 commit comments

Comments
 (0)