Skip to content

Commit 95b853c

Browse files
committed
more type sanity checks in Miri
1 parent ad7179d commit 95b853c

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

src/librustc_mir/interpret/operand.rs

+7
Original file line numberDiff line numberDiff line change
@@ -469,6 +469,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
469469
.try_fold(base_op, |op, elem| self.operand_projection(op, elem))?;
470470

471471
trace!("eval_place_to_op: got {:?}", *op);
472+
// Sanity-check the type we ended up with.
473+
debug_assert_eq!(
474+
self.subst_from_current_frame_and_normalize_erasing_regions(
475+
place.ty(&self.frame().body.local_decls, *self.tcx).ty
476+
),
477+
op.layout.ty,
478+
);
472479
Ok(op)
473480
}
474481

src/librustc_mir/interpret/place.rs

+7
Original file line numberDiff line numberDiff line change
@@ -638,6 +638,13 @@ where
638638
}
639639

640640
self.dump_place(place_ty.place);
641+
// Sanity-check the type we ended up with.
642+
debug_assert_eq!(
643+
self.subst_from_current_frame_and_normalize_erasing_regions(
644+
place.ty(&self.frame().body.local_decls, *self.tcx).ty
645+
),
646+
place_ty.layout.ty,
647+
);
641648
Ok(place_ty)
642649
}
643650

0 commit comments

Comments
 (0)