1
Fork 0

check array type of repeat exprs is wf

This commit is contained in:
Boxy 2023-05-02 18:04:52 +01:00
parent 6f8c0557e0
commit c04106f9f1
10 changed files with 96 additions and 6 deletions

View file

@ -108,6 +108,14 @@ impl<'a, 'tcx> MutVisitor<'tcx> for RegionRenumberer<'a, 'tcx> {
debug!(?region);
}
#[instrument(skip(self), level = "debug")]
fn visit_ty_const(&mut self, ct: &mut ty::Const<'tcx>, location: Location) {
let old_ct = *ct;
*ct = self.renumber_regions(old_ct, || RegionCtxt::Location(location));
debug!(?ct);
}
#[instrument(skip(self), level = "debug")]
fn visit_constant(&mut self, constant: &mut Constant<'tcx>, location: Location) {
let literal = constant.literal;

View file

@ -1803,6 +1803,13 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> {
Rvalue::Repeat(operand, len) => {
self.check_operand(operand, location);
let array_ty = rvalue.ty(body.local_decls(), tcx);
self.prove_predicate(
ty::PredicateKind::WellFormed(array_ty.into()),
Locations::Single(location),
ConstraintCategory::Boring,
);
// If the length cannot be evaluated we must assume that the length can be larger
// than 1.
// If the length is larger than 1, the repeat expression will need to copy the