Skip to content

Commit 9cc28d4

Browse files
committed
Replace MemoryExtra by Memory in intptrcast methods
1 parent b25ee64 commit 9cc28d4

File tree

2 files changed

+8
-9
lines changed

2 files changed

+8
-9
lines changed

Diff for: src/librustc_mir/interpret/machine.rs

+6-7
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,7 @@ use rustc::ty::{self, query::TyCtxtAt};
1111

1212
use super::{
1313
Allocation, AllocId, InterpResult, Scalar, AllocationExtra,
14-
InterpretCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer,
15-
InterpErrorInfo, InterpError
14+
InterpretCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer, Memory
1615
};
1716

1817
/// Whether this kind of memory is allowed to leak
@@ -212,19 +211,19 @@ pub trait Machine<'mir, 'tcx>: Sized {
212211

213212
fn int_to_ptr(
214213
int: u64,
215-
_extra: &Self::MemoryExtra,
214+
_mem: &Memory<'mir, 'tcx, Self>,
216215
) -> InterpResult<'tcx, Pointer<Self::PointerTag>> {
217216
if int == 0 {
218-
Err(InterpErrorInfo::from(InterpError::InvalidNullPointerUsage))
217+
err!(InvalidNullPointerUsage)
219218
} else {
220-
Err(InterpErrorInfo::from(InterpError::ReadBytesAsPointer))
219+
err!(ReadBytesAsPointer)
221220
}
222221
}
223222

224223
fn ptr_to_int(
225224
_ptr: Pointer<Self::PointerTag>,
226-
_extra: &Self::MemoryExtra,
225+
_mem: &Memory<'mir, 'tcx, Self>,
227226
) -> InterpResult<'tcx, u64> {
228-
Err(InterpErrorInfo::from(InterpError::ReadPointerAsBytes))
227+
err!(ReadPointerAsBytes)
229228
}
230229
}

Diff for: src/librustc_mir/interpret/memory.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -881,7 +881,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
881881
) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
882882
match scalar {
883883
Scalar::Ptr(ptr) => Ok(ptr),
884-
_ => M::int_to_ptr(scalar.to_usize(self)?, &self.extra)
884+
_ => M::int_to_ptr(scalar.to_usize(self)?, self)
885885
}
886886
}
887887

@@ -892,7 +892,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> {
892892
) -> InterpResult<'tcx, u128> {
893893
match scalar.to_bits_or_ptr(size, self) {
894894
Ok(bits) => Ok(bits),
895-
Err(ptr) => Ok(M::ptr_to_int(ptr, &self.extra)? as u128)
895+
Err(ptr) => Ok(M::ptr_to_int(ptr, self)? as u128)
896896
}
897897
}
898898
}

0 commit comments

Comments
 (0)