Skip to content

Commit 5443f7b

Browse files
authored
Rollup merge of #55345 - RalfJung:no-null, r=oli-obk
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
2 parents 83906ec + cbe6b22 commit 5443f7b

File tree

1 file changed

+1
-9
lines changed

1 file changed

+1
-9
lines changed

src/librustc/mir/interpret/value.rs

+1-9
Original file line numberDiff line numberDiff line change
@@ -181,22 +181,14 @@ impl<'tcx, Tag> Scalar<Tag> {
181181
#[inline]
182182
pub fn is_null_ptr(self, cx: impl HasDataLayout) -> bool {
183183
match self {
184-
Scalar::Bits { bits, size } => {
184+
Scalar::Bits { bits, size } => {
185185
assert_eq!(size as u64, cx.data_layout().pointer_size.bytes());
186186
bits == 0
187187
},
188188
Scalar::Ptr(_) => false,
189189
}
190190
}
191191

192-
#[inline]
193-
pub fn is_null(self) -> bool {
194-
match self {
195-
Scalar::Bits { bits, .. } => bits == 0,
196-
Scalar::Ptr(_) => false
197-
}
198-
}
199-
200192
#[inline]
201193
pub fn from_bool(b: bool) -> Self {
202194
Scalar::Bits { bits: b as u128, size: 1 }

0 commit comments

Comments
 (0)