Skip to content

Commit

Permalink
Rollup merge of rust-lang#55345 - RalfJung:no-null, r=oli-obk
Browse files Browse the repository at this point in the history
Remove is_null

It was confusingly named (`is_zero` would have been better, as someone pointed out somewhere but I forgot who or where), and it didn't even reliably test for "is this value 0 at run-time" because out-of-bounds pointers *can* be 0.

It's not used in rustc, and miri only really needs `is_null_ptr` and `to_bytes() == 0`, so let's just kill this method.

r? @oli-obk
  • Loading branch information
pietroalbini committed Oct 25, 2018
2 parents 83906ec + cbe6b22 commit 5443f7b
Showing 1 changed file with 1 addition and 9 deletions.
10 changes: 1 addition & 9 deletions src/librustc/mir/interpret/value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -181,22 +181,14 @@ impl<'tcx, Tag> Scalar<Tag> {
#[inline]
pub fn is_null_ptr(self, cx: impl HasDataLayout) -> bool {
match self {
Scalar::Bits { bits, size } => {
Scalar::Bits { bits, size } => {
assert_eq!(size as u64, cx.data_layout().pointer_size.bytes());
bits == 0
},
Scalar::Ptr(_) => false,
}
}

#[inline]
pub fn is_null(self) -> bool {
match self {
Scalar::Bits { bits, .. } => bits == 0,
Scalar::Ptr(_) => false
}
}

#[inline]
pub fn from_bool(b: bool) -> Self {
Scalar::Bits { bits: b as u128, size: 1 }
Expand Down

0 comments on commit 5443f7b

Please sign in to comment.