about summary refs log tree commit diff
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2020-02-28 14:08:48 +0100
committerRalf Jung <post@ralfj.de>2020-02-28 16:07:12 +0100
commit0e157380ae2a7af0c457aea1c8be22161899ea1d (patch)
tree5f45017b098602bcb186ba0abdfc32cec74058cf
parent63c77f1bd0beee9c3ee75cc41c507e31d3a72a5d (diff)
downloadrust-0e157380ae2a7af0c457aea1c8be22161899ea1d.tar.gz
rust-0e157380ae2a7af0c457aea1c8be22161899ea1d.zip
move ZST assertion up, for better errors
-rw-r--r--src/librustc/mir/interpret/value.rs4
1 files changed, 2 insertions, 2 deletions
diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs
index c931fcf71e3..2be60d35af3 100644
--- a/src/librustc/mir/interpret/value.rs
+++ b/src/librustc/mir/interpret/value.rs
@@ -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)
             }
@@ -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)
             }