Skip to content

Commit

Permalink
Auto merge of #131006 - RalfJung:immediate-sanity, r=<try>
Browse files Browse the repository at this point in the history
interpret: always enable write_immediate sanity checks

Writing a wrongly-sized scalar somewhere can have quite confusing effects. Let's see how expensive it is to catch this early.
  • Loading branch information
bors committed Sep 29, 2024
2 parents 1d9162b + fe181de commit e81d217
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions compiler/rustc_const_eval/src/interpret/place.rs
Original file line number Diff line number Diff line change
Expand Up @@ -652,9 +652,7 @@ where
M::after_local_write(self, local, /*storage_live*/ false)?;
}
// Double-check that the value we are storing and the local fit to each other.
if cfg!(debug_assertions) {
src.assert_matches_abi(local_layout.abi, self);
}
src.assert_matches_abi(local_layout.abi, self);
}
Left(mplace) => {
self.write_immediate_to_mplace_no_validate(src, mplace.layout, mplace.mplace)?;
Expand All @@ -672,9 +670,8 @@ where
layout: TyAndLayout<'tcx>,
dest: MemPlace<M::Provenance>,
) -> InterpResult<'tcx> {
if cfg!(debug_assertions) {
value.assert_matches_abi(layout.abi, self);
}
// Ensure the value matches the type of the place it is written to.
value.assert_matches_abi(layout.abi, self);
// Note that it is really important that the type here is the right one, and matches the
// type things are read at. In case `value` is a `ScalarPair`, we don't do any magic here
// to handle padding properly, which is only correct if we never look at this data with the
Expand Down

0 comments on commit e81d217

Please sign in to comment.