1
Fork 0

Remove is_null

It was confusingly named (`is_zero` would have been better), and it didn't even
reliably test for "is this value 0 at run-time" because out-of-bounds pointers
*can* be 0.
This commit is contained in:
Ralf Jung 2018-10-25 11:39:54 +02:00
parent f99911a4a0
commit cbe6b2298a

View file

@ -181,7 +181,7 @@ impl<'tcx, Tag> Scalar<Tag> {
#[inline] #[inline]
pub fn is_null_ptr(self, cx: impl HasDataLayout) -> bool { pub fn is_null_ptr(self, cx: impl HasDataLayout) -> bool {
match self { match self {
Scalar::Bits { bits, size } => { Scalar::Bits { bits, size } => {
assert_eq!(size as u64, cx.data_layout().pointer_size.bytes()); assert_eq!(size as u64, cx.data_layout().pointer_size.bytes());
bits == 0 bits == 0
}, },
@ -189,14 +189,6 @@ impl<'tcx, Tag> Scalar<Tag> {
} }
} }
#[inline]
pub fn is_null(self) -> bool {
match self {
Scalar::Bits { bits, .. } => bits == 0,
Scalar::Ptr(_) => false
}
}
#[inline] #[inline]
pub fn from_bool(b: bool) -> Self { pub fn from_bool(b: bool) -> Self {
Scalar::Bits { bits: b as u128, size: 1 } Scalar::Bits { bits: b as u128, size: 1 }