From 0e157380ae2a7af0c457aea1c8be22161899ea1d Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Fri, 28 Feb 2020 14:08:48 +0100 Subject: [PATCH] move ZST assertion up, for better errors --- src/librustc/mir/interpret/value.rs | 4 ++-- 1 file 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 @@ pub fn to_bits_or_ptr( target_size: Size, cx: &impl HasDataLayout, ) -> Result> { + 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 @@ pub fn to_bits_or_ptr( /// 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) } -- 2.44.0