Skip to content

Commit 7a7b853

Browse files
committed
adjust for rustc changes
1 parent 3c930e4 commit 7a7b853

File tree

2 files changed

+13
-14
lines changed

2 files changed

+13
-14
lines changed

src/fn_call.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -607,11 +607,12 @@ pub trait EvalContextExt<'a, 'mir, 'tcx: 'a + 'mir>: crate::MiriEvalContextExt<'
607607
// Extract the function type out of the signature (that seems easier than constructing it ourselves).
608608
let dtor = match this.read_scalar(args[1])?.not_undef()? {
609609
Scalar::Ptr(dtor_ptr) => Some(this.memory().get_fn(dtor_ptr)?),
610-
Scalar::Bits { bits: 0, size } => {
610+
Scalar::Raw { data: 0, size } => {
611+
// NULL pointer
611612
assert_eq!(size as u64, this.memory().pointer_size().bytes());
612613
None
613614
},
614-
Scalar::Bits { .. } => return err!(ReadBytesAsPointer),
615+
Scalar::Raw { .. } => return err!(ReadBytesAsPointer),
615616
};
616617

617618
// Figure out how large a pthread TLS key actually is.

src/operator.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
141141
) -> EvalResult<'tcx, bool> {
142142
let size = self.pointer_size();
143143
Ok(match (left, right) {
144-
(Scalar::Bits { .. }, Scalar::Bits { .. }) =>
144+
(Scalar::Raw { .. }, Scalar::Raw { .. }) =>
145145
left.to_bits(size)? == right.to_bits(size)?,
146146
(Scalar::Ptr(left), Scalar::Ptr(right)) => {
147147
// Comparison illegal if one of them is out-of-bounds, *unless* they
@@ -165,10 +165,10 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
165165
}
166166
}
167167
// Comparing ptr and integer.
168-
(Scalar::Ptr(ptr), Scalar::Bits { bits, size }) |
169-
(Scalar::Bits { bits, size }, Scalar::Ptr(ptr)) => {
168+
(Scalar::Ptr(ptr), Scalar::Raw { data, size }) |
169+
(Scalar::Raw { data, size }, Scalar::Ptr(ptr)) => {
170170
assert_eq!(size as u64, self.pointer_size().bytes());
171-
let bits = bits as u64;
171+
let bits = data as u64;
172172

173173
// Case I: Comparing real pointers with "small" integers.
174174
// Really we should only do this for NULL, but pragmatically speaking on non-bare-metal systems,
@@ -262,7 +262,7 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
262262
// Truncate (shift left to drop out leftover values, shift right to fill with zeroes).
263263
(value << shift) >> shift
264264
};
265-
let ptr_size = self.memory().pointer_size().bytes() as u8;
265+
let ptr_size = self.memory().pointer_size();
266266
trace!("ptr BitAnd, align {}, operand {:#010x}, base_mask {:#010x}",
267267
ptr_base_align, right, base_mask);
268268
if right & base_mask == base_mask {
@@ -278,7 +278,8 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
278278
)
279279
} else if right & base_mask == 0 {
280280
// Case 2: the base address bits are all taken away, i.e., right is all-0 there.
281-
(Scalar::Bits { bits: (left.offset.bytes() as u128) & right, size: ptr_size }, false)
281+
let v = Scalar::from_uint((left.offset.bytes() as u128) & right, ptr_size);
282+
(v, false)
282283
} else {
283284
return err!(ReadPointerAsBytes);
284285
}
@@ -289,18 +290,15 @@ impl<'a, 'mir, 'tcx> EvalContextExt<'tcx> for super::MiriEvalContext<'a, 'mir, '
289290
// (Intuition: modulo a divisor leaks less information.)
290291
let ptr_base_align = self.memory().get(left.alloc_id)?.align.bytes();
291292
let right = right as u64;
292-
let ptr_size = self.memory().pointer_size().bytes() as u8;
293+
let ptr_size = self.memory().pointer_size();
293294
if right == 1 {
294295
// Modulo 1 is always 0.
295-
(Scalar::Bits { bits: 0, size: ptr_size }, false)
296+
(Scalar::from_uint(0u32, ptr_size), false)
296297
} else if ptr_base_align % right == 0 {
297298
// The base address would be cancelled out by the modulo operation, so we can
298299
// just take the modulo of the offset.
299300
(
300-
Scalar::Bits {
301-
bits: (left.offset.bytes() % right) as u128,
302-
size: ptr_size
303-
},
301+
Scalar::from_uint((left.offset.bytes() % right) as u128, ptr_size),
304302
false,
305303
)
306304
} else {

0 commit comments

Comments
 (0)