Skip to content

Commit 0e15738

Browse files
committed
move ZST assertion up, for better errors
1 parent 63c77f1 commit 0e15738

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/librustc/mir/interpret/value.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -368,10 +368,10 @@ impl<'tcx, Tag> Scalar<Tag> {
368368
target_size: Size,
369369
cx: &impl HasDataLayout,
370370
) -> Result<u128, Pointer<Tag>> {
371+
assert_ne!(target_size.bytes(), 0, "you should never look at the bits of a ZST");
371372
match self {
372373
Scalar::Raw { data, size } => {
373374
assert_eq!(target_size.bytes(), size as u64);
374-
assert_ne!(size, 0, "you should never look at the bits of a ZST");
375375
Scalar::check_data(data, size);
376376
Ok(data)
377377
}
@@ -386,10 +386,10 @@ impl<'tcx, Tag> Scalar<Tag> {
386386
/// It is just a helper for other methods in this file.
387387
#[inline]
388388
fn to_bits(self, target_size: Size) -> InterpResult<'tcx, u128> {
389+
assert_ne!(target_size.bytes(), 0, "you should never look at the bits of a ZST");
389390
match self {
390391
Scalar::Raw { data, size } => {
391392
assert_eq!(target_size.bytes(), size as u64);
392-
assert_ne!(size, 0, "you should never look at the bits of a ZST");
393393
Scalar::check_data(data, size);
394394
Ok(data)
395395
}

0 commit comments

Comments
 (0)