Skip to content

Commit 46de12a

Browse files
committed
Switch to eval_const_expr_partial in trans::consts.
However, I left the ICEs rather than switching to nicer error reporting there; these cases *should* be detected prior to hitting trans, and thus ICE'ing here is appropriate. (So why switch to `eval_const_expr_partial`? Because I want to try to eliminate all uses of `eval_const_expr` entirely.)
1 parent 5d950bd commit 46de12a

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

src/librustc_trans/trans/consts.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -462,9 +462,9 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
462462

463463
ast::ExprIndex(ref base, ref index) => {
464464
let (bv, bt) = const_expr(cx, &**base, param_substs);
465-
let iv = match const_eval::eval_const_expr(cx.tcx(), &**index) {
466-
const_eval::const_int(i) => i as u64,
467-
const_eval::const_uint(u) => u,
465+
let iv = match const_eval::eval_const_expr_partial(cx.tcx(), &**index, None) {
466+
Ok(const_eval::const_int(i)) => i as u64,
467+
Ok(const_eval::const_uint(u)) => u,
468468
_ => cx.sess().span_bug(index.span,
469469
"index is not an integer-constant expression")
470470
};
@@ -650,9 +650,9 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>,
650650
ast::ExprRepeat(ref elem, ref count) => {
651651
let unit_ty = ty::sequence_element_type(cx.tcx(), ety);
652652
let llunitty = type_of::type_of(cx, unit_ty);
653-
let n = match const_eval::eval_const_expr(cx.tcx(), &**count) {
654-
const_eval::const_int(i) => i as uint,
655-
const_eval::const_uint(i) => i as uint,
653+
let n = match const_eval::eval_const_expr_partial(cx.tcx(), &**count, None) {
654+
Ok(const_eval::const_int(i)) => i as uint,
655+
Ok(const_eval::const_uint(i)) => i as uint,
656656
_ => cx.sess().span_bug(count.span, "count must be integral const expression.")
657657
};
658658
let unit_val = const_expr(cx, &**elem, param_substs).0;

0 commit comments

Comments
 (0)