From 9cc28d454157dce3885980012dd12e592ce74cc2 Mon Sep 17 00:00:00 2001 From: Christian Poveda Date: Thu, 20 Jun 2019 14:07:34 -0500 Subject: [PATCH] Replace MemoryExtra by Memory in intptrcast methods --- src/librustc_mir/interpret/machine.rs | 13 ++++++------- src/librustc_mir/interpret/memory.rs | 4 ++-- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 2581c134b266..f06c0314919a 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -11,8 +11,7 @@ use rustc::ty::{self, query::TyCtxtAt}; use super::{ Allocation, AllocId, InterpResult, Scalar, AllocationExtra, - InterpretCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer, - InterpErrorInfo, InterpError + InterpretCx, PlaceTy, OpTy, ImmTy, MemoryKind, Pointer, Memory }; /// Whether this kind of memory is allowed to leak @@ -212,19 +211,19 @@ pub trait Machine<'mir, 'tcx>: Sized { fn int_to_ptr( int: u64, - _extra: &Self::MemoryExtra, + _mem: &Memory<'mir, 'tcx, Self>, ) -> InterpResult<'tcx, Pointer> { if int == 0 { - Err(InterpErrorInfo::from(InterpError::InvalidNullPointerUsage)) + err!(InvalidNullPointerUsage) } else { - Err(InterpErrorInfo::from(InterpError::ReadBytesAsPointer)) + err!(ReadBytesAsPointer) } } fn ptr_to_int( _ptr: Pointer, - _extra: &Self::MemoryExtra, + _mem: &Memory<'mir, 'tcx, Self>, ) -> InterpResult<'tcx, u64> { - Err(InterpErrorInfo::from(InterpError::ReadPointerAsBytes)) + err!(ReadPointerAsBytes) } } diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index a0a34df3a5ea..1351d154df7c 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -881,7 +881,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { ) -> InterpResult<'tcx, Pointer> { match scalar { Scalar::Ptr(ptr) => Ok(ptr), - _ => M::int_to_ptr(scalar.to_usize(self)?, &self.extra) + _ => M::int_to_ptr(scalar.to_usize(self)?, self) } } @@ -892,7 +892,7 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'mir, 'tcx, M> { ) -> InterpResult<'tcx, u128> { match scalar.to_bits_or_ptr(size, self) { Ok(bits) => Ok(bits), - Err(ptr) => Ok(M::ptr_to_int(ptr, &self.extra)? as u128) + Err(ptr) => Ok(M::ptr_to_int(ptr, self)? as u128) } } }