1
Fork 0

Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU

Allow `_` as the length of array types and repeat expressions

r? `@BoxyUwU` cc `@varkor`
This commit is contained in:
Matthias Krüger 2022-01-04 21:23:06 +01:00 committed by GitHub
commit ac7a867715
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
28 changed files with 268 additions and 85 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 }
}