Skip to content

Commit

Permalink
move ZST assertion up, for better errors
Browse files Browse the repository at this point in the history
  • Loading branch information
RalfJung committed Feb 28, 2020
1 parent 63c77f1 commit 0e15738
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -368,10 +368,10 @@ impl<'tcx, Tag> Scalar<Tag> {
target_size: Size,
cx: &impl HasDataLayout,
) -> Result<u128, Pointer<Tag>> {
assert_ne!(target_size.bytes(), 0, "you should never look at the bits of a ZST");
match self {
Scalar::Raw { data, size } => {
assert_eq!(target_size.bytes(), size as u64);
assert_ne!(size, 0, "you should never look at the bits of a ZST");
Scalar::check_data(data, size);
Ok(data)
}
Expand All @@ -386,10 +386,10 @@ impl<'tcx, Tag> Scalar<Tag> {
/// It is just a helper for other methods in this file.
#[inline]
fn to_bits(self, target_size: Size) -> InterpResult<'tcx, u128> {
assert_ne!(target_size.bytes(), 0, "you should never look at the bits of a ZST");
match self {
Scalar::Raw { data, size } => {
assert_eq!(target_size.bytes(), size as u64);
assert_ne!(size, 0, "you should never look at the bits of a ZST");
Scalar::check_data(data, size);
Ok(data)
}
Expand Down

0 comments on commit 0e15738

Please sign in to comment.