Skip to content

Commit 3d2fd36

Browse files
committed
Explicitly check type of array len const
Previously, this was implicitly checked when checking the anon const. But now, since const args are no longer always anon consts, this needs to be done manually.
1 parent 999c9c6 commit 3d2fd36

File tree

1 file changed

+12
-2
lines changed
  • compiler/rustc_trait_selection/src/traits

1 file changed

+12
-2
lines changed

compiler/rustc_trait_selection/src/traits/wf.rs

+12-2
Original file line numberDiff line numberDiff line change
@@ -680,9 +680,19 @@ impl<'a, 'tcx> TypeVisitor<TyCtxt<'tcx>> for WfPredicates<'a, 'tcx> {
680680
self.require_sized(subty, ObligationCauseCode::SliceOrArrayElem);
681681
}
682682

683-
ty::Array(subty, _) => {
683+
ty::Array(subty, len) => {
684684
self.require_sized(subty, ObligationCauseCode::SliceOrArrayElem);
685-
// Note that we handle the len is implicitly checked while walking `arg`.
685+
let cause = self.cause(ObligationCauseCode::Misc);
686+
self.out.push(traits::Obligation::with_depth(
687+
tcx,
688+
cause,
689+
self.recursion_depth,
690+
self.param_env,
691+
ty::Binder::dummy(ty::PredicateKind::Clause(ty::ClauseKind::ConstArgHasType(
692+
len,
693+
tcx.types.usize,
694+
))),
695+
));
686696
}
687697

688698
ty::Pat(subty, _) => {

0 commit comments

Comments
 (0)