Skip to content

Commit

Permalink
Sanity abort to_bits if used on zsts
Browse files Browse the repository at this point in the history
  • Loading branch information
oli-obk committed May 25, 2018
1 parent eceeb63 commit 50d3783
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ impl<'tcx> Scalar {

pub fn to_bits(self, size: Size) -> EvalResult<'tcx, u128> {
match self {
Scalar::Bits { defined: 0, .. } => err!(ReadUndefBytes),
Scalar::Bits { .. } if size.bits() == 0 => bug!("to_bits cannot be used with zsts"),
Scalar::Bits { bits, defined } if size.bits() <= defined as u64 => Ok(bits),
Scalar::Bits { .. } => err!(ReadUndefBytes),
Scalar::Ptr(_) => err!(ReadPointerAsBytes),
Expand Down

0 comments on commit 50d3783

Please sign in to comment.