BorrowedRef {lifetime: l.clean(cx), mutability: m.mutbl.clean(cx),
type_: box m.ty.clean(cx)},
TyVec(ref ty) => Vector(box ty.clean(cx)),
- TyFixedLengthVec(ref ty, ref e) =>
- FixedVector(box ty.clean(cx), pprust::expr_to_string(e)),
+ TyFixedLengthVec(ref ty, ref e) => {
+ let n = if let Some(tcx) = cx.tcx_opt() {
+ use rustc_const_math::{ConstInt, ConstUsize};
+ use rustc_const_eval::eval_const_expr;
+ use rustc::middle::const_val::ConstVal;
+ match eval_const_expr(tcx, e) {
+ ConstVal::Integral(ConstInt::Usize(u)) => match u {
+ ConstUsize::Us16(u) => u.to_string(),
+ ConstUsize::Us32(u) => u.to_string(),
+ ConstUsize::Us64(u) => u.to_string(),
+ },
+ // after type checking this can't fail
+ _ => unreachable!(),
+ }
+ } else {
+ pprust::expr_to_string(e)
+ };
+ FixedVector(box ty.clean(cx), n)
+ },
TyTup(ref tys) => Tuple(tys.clean(cx)),
TyPath(None, ref p) => {
resolve_type(cx, p.clean(cx), self.id)