From 2243a2cceddd6c9708e3d296b5375da72a6b3d2a Mon Sep 17 00:00:00 2001 From: "Felix S. Klock II" Date: Wed, 1 Apr 2015 02:40:56 +0200 Subject: [PATCH] Unify handling of checking repeat-count validity. --- src/librustc_trans/trans/consts.rs | 14 +------------- 1 file changed, 1 insertion(+), 13 deletions(-) diff --git a/src/librustc_trans/trans/consts.rs b/src/librustc_trans/trans/consts.rs index cf4675cbe46..c32cb28ec78 100644 --- a/src/librustc_trans/trans/consts.rs +++ b/src/librustc_trans/trans/consts.rs @@ -772,19 +772,7 @@ fn const_expr_unadjusted<'a, 'tcx>(cx: &CrateContext<'a, 'tcx>, ast::ExprRepeat(ref elem, ref count) => { let unit_ty = ty::sequence_element_type(cx.tcx(), ety); let llunitty = type_of::type_of(cx, unit_ty); - let n = match const_eval::eval_const_expr_partial(cx.tcx(), &**count, None) { - Ok(const_eval::const_int(i)) => i as usize, - Ok(const_eval::const_uint(i)) => i as usize, - Ok(_) => { - cx.sess().span_bug(count.span, "count must be integral const expression.") - } - Err(err) => { - cx.sess().span_err(count.span, &format!("error evaluating count: {}", - err.description())); - // return 1 to allow compilation to proceed - 1 as usize - } - }; + let n = ty::eval_repeat_count(cx.tcx(), count); let unit_val = const_expr(cx, &**elem, param_substs).0; let vs: Vec<_> = repeat(unit_val).take(n).collect(); if val_ty(unit_val) != llunitty {