Skip to content

Commit

Permalink
more type sanity checks in Miri
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed May 25, 2020
1 parent ad7179d commit 95b853c
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 0 deletions.
7 changes: 7 additions & 0 deletions src/librustc_mir/interpret/operand.rs
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,13 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
.try_fold(base_op, |op, elem| self.operand_projection(op, elem))?;

trace!("eval_place_to_op: got {:?}", *op);
// Sanity-check the type we ended up with.
debug_assert_eq!(
self.subst_from_current_frame_and_normalize_erasing_regions(
place.ty(&self.frame().body.local_decls, *self.tcx).ty
),
op.layout.ty,
);
Ok(op)
}

Expand Down
7 changes: 7 additions & 0 deletions src/librustc_mir/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -638,6 +638,13 @@ where
}

self.dump_place(place_ty.place);
// Sanity-check the type we ended up with.
debug_assert_eq!(
self.subst_from_current_frame_and_normalize_erasing_regions(
place.ty(&self.frame().body.local_decls, *self.tcx).ty
),
place_ty.layout.ty,
);
Ok(place_ty)
}

Expand Down

0 comments on commit 95b853c

Please sign in to comment.