diff options
| author | Matthias Krüger <matthias.krueger@famsik.de> | 2022-01-04 21:23:06 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-01-04 21:23:06 +0100 |
| commit | ac7a8677155b911c27ee28f2f0d1a359686fa774 (patch) | |
| tree | 597cb35450fbc6fc014ca4ac8a51a3aef08d9153 /compiler/rustc_mir_build | |
| parent | d49c692eeba97381570f0a0f3167b4c44c80bc0a (diff) | |
| parent | a02bf76c9667ad7a25df3b672b3748398451a3d0 (diff) | |
| download | rust-ac7a8677155b911c27ee28f2f0d1a359686fa774.tar.gz rust-ac7a8677155b911c27ee28f2f0d1a359686fa774.zip | |
Rollup merge of #91907 - lcnr:const-arg-infer, r=BoxyUwU
Allow `_` as the length of array types and repeat expressions r? `@BoxyUwU` cc `@varkor`
Diffstat (limited to 'compiler/rustc_mir_build')
| -rw-r--r-- | compiler/rustc_mir_build/src/thir/cx/expr.rs | 9 |
1 files changed, 6 insertions, 3 deletions
diff --git a/compiler/rustc_mir_build/src/thir/cx/expr.rs b/compiler/rustc_mir_build/src/thir/cx/expr.rs index 092fe131174..bdde6b4a356 100644 --- a/compiler/rustc_mir_build/src/thir/cx/expr.rs +++ b/compiler/rustc_mir_build/src/thir/cx/expr.rs @@ -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 } } |
