We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent a0074ca commit 7b7c6ceCopy full SHA for 7b7c6ce
src/librustc/mir/interpret/value.rs
@@ -202,6 +202,19 @@ impl<'tcx, Tag> Scalar<Tag> {
202
}
203
204
205
+ /// Returns this pointers offset from the allocation base, or from NULL (for
206
+ /// integer pointers).
207
+ #[inline]
208
+ pub fn get_ptr_offset(self, cx: &impl HasDataLayout) -> Size {
209
+ match self {
210
+ Scalar::Bits { bits, size } => {
211
+ assert_eq!(size as u64, cx.pointer_size().bytes());
212
+ Size::from_bytes(bits as u64)
213
+ }
214
+ Scalar::Ptr(ptr) => ptr.offset,
215
216
217
+
218
#[inline]
219
pub fn is_null_ptr(self, cx: &impl HasDataLayout) -> bool {
220
match self {
0 commit comments