Skip to content

Commit cbe6b22

Browse files
committed
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.
1 parent f99911a commit cbe6b22

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)