Skip to content

Commit 98b70c9

Browse files
committed
Simplify assert_bits impl
1 parent dad0036 commit 98b70c9

File tree

1 file changed

+3
-4
lines changed
  • compiler/rustc_middle/src/ty/consts

1 file changed

+3
-4
lines changed

compiler/rustc_middle/src/ty/consts/int.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -225,10 +225,9 @@ impl ScalarInt {
225225

226226
#[inline]
227227
pub fn assert_bits(self, target_size: Size) -> u128 {
228-
assert_ne!(target_size.bytes(), 0, "you should never look at the bits of a ZST");
229-
assert_eq!(target_size.bytes(), u64::from(self.size));
230-
self.check_data();
231-
self.data
228+
self.to_bits(target_size).unwrap_or_else(|size| {
229+
bug!("int of size {}, but is {}", target_size.bytes(), size.bytes())
230+
})
232231
}
233232

234233
#[inline]

0 commit comments

Comments
 (0)