1
Fork 0

implement generic_arg_infer for array lengths

This commit is contained in:
lcnr 2021-12-23 10:01:51 +01:00
parent 5aa0239b16
commit e3f5cc6c38
19 changed files with 161 additions and 51 deletions

View file

@ -583,9 +583,12 @@ impl<'tcx> Cx<'tcx> {
ExprKind::ConstBlock { value }
}
// Now comes the rote stuff:
hir::ExprKind::Repeat(ref v, ref count) => {
let count_def_id = self.tcx.hir().local_def_id(count.hir_id);
let count = ty::Const::from_anon_const(self.tcx, count_def_id);
hir::ExprKind::Repeat(ref v, _) => {
let ty = self.typeck_results().expr_ty(expr);
let count = match ty.kind() {
ty::Array(_, ct) => ct,
_ => span_bug!(expr.span, "unexpected repeat expr ty: {:?}", ty),
};
ExprKind::Repeat { value: self.mirror_expr(v), count }
}