diff --git a/src/librustc/ich/impls_ty.rs b/src/librustc/ich/impls_ty.rs index f568bba57b6..155efd0c43e 100644 --- a/src/librustc/ich/impls_ty.rs +++ b/src/librustc/ich/impls_ty.rs @@ -415,7 +415,7 @@ impl_stable_hash_for!(enum mir::interpret::Value { ByRef(ptr, align) }); -impl_stable_hash_for!(struct mir::interpret::MemoryPointer { +impl_stable_hash_for!(struct mir::interpret::Pointer { alloc_id, offset }); diff --git a/src/librustc/mir/interpret/error.rs b/src/librustc/mir/interpret/error.rs index 6885bf89cc8..45819afca3f 100644 --- a/src/librustc/mir/interpret/error.rs +++ b/src/librustc/mir/interpret/error.rs @@ -5,7 +5,7 @@ use ty::{FnSig, Ty, layout}; use ty::layout::{Size, Align}; use super::{ - MemoryPointer, Lock, AccessKind + Pointer, Lock, AccessKind }; use backtrace::Backtrace; @@ -38,7 +38,7 @@ pub enum EvalErrorKind<'tcx, O> { MachineError(String), FunctionPointerTyMismatch(FnSig<'tcx>, FnSig<'tcx>), NoMirFor(String), - UnterminatedCString(MemoryPointer), + UnterminatedCString(Pointer), DanglingPointerDeref, DoubleFree, InvalidMemoryAccess, @@ -46,7 +46,7 @@ pub enum EvalErrorKind<'tcx, O> { InvalidBool, InvalidDiscriminant, PointerOutOfBounds { - ptr: MemoryPointer, + ptr: Pointer, access: bool, allocation_size: Size, }, @@ -76,26 +76,26 @@ pub enum EvalErrorKind<'tcx, O> { has: Align, }, MemoryLockViolation { - ptr: MemoryPointer, + ptr: Pointer, len: u64, frame: usize, access: AccessKind, lock: Lock, }, MemoryAcquireConflict { - ptr: MemoryPointer, + ptr: Pointer, len: u64, kind: AccessKind, lock: Lock, }, InvalidMemoryLockRelease { - ptr: MemoryPointer, + ptr: Pointer, len: u64, frame: usize, lock: Lock, }, DeallocatedLockedMemory { - ptr: MemoryPointer, + ptr: Pointer, lock: Lock, }, ValidationFailure(String), diff --git a/src/librustc/mir/interpret/mod.rs b/src/librustc/mir/interpret/mod.rs index 5a5aea0f751..397e4fdc940 100644 --- a/src/librustc/mir/interpret/mod.rs +++ b/src/librustc/mir/interpret/mod.rs @@ -110,22 +110,22 @@ impl PointerArithmetic for T {} #[derive(Copy, Clone, Debug, Eq, PartialEq, Ord, PartialOrd, RustcEncodable, RustcDecodable, Hash)] -pub struct MemoryPointer { +pub struct Pointer { pub alloc_id: AllocId, pub offset: Size, } -impl<'tcx> MemoryPointer { +impl<'tcx> Pointer { pub fn new(alloc_id: AllocId, offset: Size) -> Self { - MemoryPointer { alloc_id, offset } + Pointer { alloc_id, offset } } pub fn zero(alloc_id: AllocId) -> Self { - MemoryPointer::new(alloc_id, Size::ZERO) + Pointer::new(alloc_id, Size::ZERO) } pub(crate) fn wrapping_signed_offset(self, i: i64, cx: C) -> Self { - MemoryPointer::new( + Pointer::new( self.alloc_id, Size::from_bytes(cx.data_layout().wrapping_signed_offset(self.offset.bytes(), i)), ) @@ -133,11 +133,11 @@ impl<'tcx> MemoryPointer { pub fn overflowing_signed_offset(self, i: i128, cx: C) -> (Self, bool) { let (res, over) = cx.data_layout().overflowing_signed_offset(self.offset.bytes(), i); - (MemoryPointer::new(self.alloc_id, Size::from_bytes(res)), over) + (Pointer::new(self.alloc_id, Size::from_bytes(res)), over) } pub(crate) fn signed_offset(self, i: i64, cx: C) -> EvalResult<'tcx, Self> { - Ok(MemoryPointer::new( + Ok(Pointer::new( self.alloc_id, Size::from_bytes(cx.data_layout().signed_offset(self.offset.bytes(), i)?), )) @@ -145,11 +145,11 @@ impl<'tcx> MemoryPointer { pub fn overflowing_offset(self, i: Size, cx: C) -> (Self, bool) { let (res, over) = cx.data_layout().overflowing_offset(self.offset.bytes(), i.bytes()); - (MemoryPointer::new(self.alloc_id, Size::from_bytes(res)), over) + (Pointer::new(self.alloc_id, Size::from_bytes(res)), over) } pub fn offset(self, i: Size, cx: C) -> EvalResult<'tcx, Self> { - Ok(MemoryPointer::new( + Ok(Pointer::new( self.alloc_id, Size::from_bytes(cx.data_layout().offset(self.offset.bytes(), i.bytes())?), )) diff --git a/src/librustc/mir/interpret/value.rs b/src/librustc/mir/interpret/value.rs index 293fa800902..53bc56cffe6 100644 --- a/src/librustc/mir/interpret/value.rs +++ b/src/librustc/mir/interpret/value.rs @@ -3,7 +3,7 @@ use ty::layout::{Align, HasDataLayout, Size}; use ty; -use super::{EvalResult, MemoryPointer, PointerArithmetic, Allocation}; +use super::{EvalResult, Pointer, PointerArithmetic, Allocation}; /// Represents a constant value in Rust. ByVal and ScalarPair are optimizations which /// matches Value's optimizations for easy conversions between these two types @@ -59,7 +59,7 @@ impl<'tcx> ConstValue<'tcx> { } #[inline] - pub fn to_ptr(&self) -> Option { + pub fn to_ptr(&self) -> Option { match self.to_primval() { Some(Scalar::Ptr(ptr)) => Some(ptr), _ => None, @@ -145,7 +145,7 @@ impl<'tcx> Scalar { Value::ScalarPair(self, Scalar::from_u128(len as u128)) } - pub fn to_value_with_vtable(self, vtable: MemoryPointer) -> Value { + pub fn to_value_with_vtable(self, vtable: Pointer) -> Value { Value::ScalarPair(self, Scalar::Ptr(vtable)) } @@ -154,8 +154,8 @@ impl<'tcx> Scalar { } } -impl From for Scalar { - fn from(ptr: MemoryPointer) -> Self { +impl From for Scalar { + fn from(ptr: Pointer) -> Self { Scalar::Ptr(ptr) } } @@ -171,8 +171,8 @@ pub enum Scalar { /// A pointer into an `Allocation`. An `Allocation` in the `memory` module has a list of /// relocations, but a `Scalar` is only large enough to contain one, so we just represent the - /// relocation and its associated offset together as a `MemoryPointer` here. - Ptr(MemoryPointer), + /// relocation and its associated offset together as a `Pointer` here. + Ptr(Pointer), /// An undefined `Scalar`, for representing values that aren't safe to examine, but are safe /// to copy around, just like undefined bytes in an `Allocation`. @@ -214,7 +214,7 @@ impl<'tcx> Scalar { } } - pub fn to_ptr(self) -> EvalResult<'tcx, MemoryPointer> { + pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { match self { Scalar::Bytes(_) => err!(ReadBytesAsPointer), Scalar::Ptr(p) => Ok(p), diff --git a/src/librustc/ty/sty.rs b/src/librustc/ty/sty.rs index 2b07c8a197f..3095027b4ef 100644 --- a/src/librustc/ty/sty.rs +++ b/src/librustc/ty/sty.rs @@ -19,7 +19,7 @@ use ty::subst::{Substs, Subst, Kind, UnpackedKind}; use ty::{self, AdtDef, TypeFlags, Ty, TyCtxt, TypeFoldable}; use ty::{Slice, TyS}; use util::captures::Captures; -use mir::interpret::{Scalar, MemoryPointer, Value, ConstValue}; +use mir::interpret::{Scalar, Pointer, Value, ConstValue}; use std::iter; use std::cmp::Ordering; @@ -1853,7 +1853,7 @@ impl<'tcx> Const<'tcx> { } #[inline] - pub fn to_ptr(&self) -> Option { + pub fn to_ptr(&self) -> Option { match self.val { ConstVal::Value(val) => val.to_ptr(), _ => None, diff --git a/src/librustc_codegen_llvm/mir/constant.rs b/src/librustc_codegen_llvm/mir/constant.rs index 0b861884f37..b1161a04128 100644 --- a/src/librustc_codegen_llvm/mir/constant.rs +++ b/src/librustc_codegen_llvm/mir/constant.rs @@ -14,7 +14,7 @@ use rustc_mir::interpret::{read_target_uint, const_val_field}; use rustc::hir::def_id::DefId; use rustc::mir; use rustc_data_structures::indexed_vec::Idx; -use rustc::mir::interpret::{GlobalId, MemoryPointer, Scalar, Allocation, ConstValue, AllocType}; +use rustc::mir::interpret::{GlobalId, Pointer, Scalar, Allocation, ConstValue, AllocType}; use rustc::ty::{self, Ty}; use rustc::ty::layout::{self, HasDataLayout, LayoutOf, Size}; use builder::Builder; @@ -96,7 +96,7 @@ pub fn const_alloc_to_llvm(cx: &CodegenCx, alloc: &Allocation) -> ValueRef { ).expect("const_alloc_to_llvm: could not read relocation pointer") as u64; llvals.push(primval_to_llvm( cx, - MemoryPointer { alloc_id, offset: Size::from_bytes(ptr_offset) }.into(), + Pointer { alloc_id, offset: Size::from_bytes(ptr_offset) }.into(), &layout::Scalar { value: layout::Primitive::Pointer, valid_range: 0..=!0 diff --git a/src/librustc_mir/hair/cx/mod.rs b/src/librustc_mir/hair/cx/mod.rs index d4b1deddad8..f633320e650 100644 --- a/src/librustc_mir/hair/cx/mod.rs +++ b/src/librustc_mir/hair/cx/mod.rs @@ -182,7 +182,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { LitKind::Str(ref s, _) => { let s = s.as_str(); let id = self.tcx.allocate_bytes(s.as_bytes()); - let ptr = MemoryPointer::zero(id); + let ptr = Pointer::zero(id); ConstValue::ScalarPair( Scalar::Ptr(ptr), Scalar::from_u128(s.len() as u128), @@ -190,7 +190,7 @@ impl<'a, 'gcx, 'tcx> Cx<'a, 'gcx, 'tcx> { }, LitKind::ByteStr(ref data) => { let id = self.tcx.allocate_bytes(data); - let ptr = MemoryPointer::zero(id); + let ptr = Pointer::zero(id); ConstValue::Scalar(ptr.into()) }, LitKind::Byte(n) => ConstValue::Scalar(Scalar::Bytes(n as u128)), diff --git a/src/librustc_mir/hair/pattern/mod.rs b/src/librustc_mir/hair/pattern/mod.rs index 640bb9d10dd..21728685230 100644 --- a/src/librustc_mir/hair/pattern/mod.rs +++ b/src/librustc_mir/hair/pattern/mod.rs @@ -1128,7 +1128,7 @@ fn lit_to_const<'a, 'tcx>(lit: &'tcx ast::LitKind, LitKind::Str(ref s, _) => { let s = s.as_str(); let id = tcx.allocate_bytes(s.as_bytes()); - let ptr = MemoryPointer::zero(id); + let ptr = Pointer::zero(id); ConstValue::ScalarPair( Scalar::Ptr(ptr), Scalar::from_u128(s.len() as u128), @@ -1136,7 +1136,7 @@ fn lit_to_const<'a, 'tcx>(lit: &'tcx ast::LitKind, }, LitKind::ByteStr(ref data) => { let id = tcx.allocate_bytes(data); - let ptr = MemoryPointer::zero(id); + let ptr = Pointer::zero(id); ConstValue::Scalar(ptr.into()) }, LitKind::Byte(n) => ConstValue::Scalar(Scalar::Bytes(n as u128)), diff --git a/src/librustc_mir/interpret/cast.rs b/src/librustc_mir/interpret/cast.rs index 050fe5291b8..674f03691a8 100644 --- a/src/librustc_mir/interpret/cast.rs +++ b/src/librustc_mir/interpret/cast.rs @@ -4,7 +4,7 @@ use syntax::ast::{FloatTy, IntTy, UintTy}; use rustc_apfloat::ieee::{Single, Double}; use super::{EvalContext, Machine}; -use rustc::mir::interpret::{Scalar, EvalResult, MemoryPointer, PointerArithmetic}; +use rustc::mir::interpret::{Scalar, EvalResult, Pointer, PointerArithmetic}; use rustc_apfloat::Float; impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { @@ -101,7 +101,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { } } - fn cast_from_ptr(&self, ptr: MemoryPointer, ty: Ty<'tcx>) -> EvalResult<'tcx, Scalar> { + fn cast_from_ptr(&self, ptr: Pointer, ty: Ty<'tcx>) -> EvalResult<'tcx, Scalar> { use rustc::ty::TypeVariants::*; match ty.sty { // Casting to a reference or fn pointer is not permitted by rustc, no need to support it here. diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index 938f0ce918e..2d14b817b8d 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -15,7 +15,7 @@ use syntax::codemap::{self, Span}; use syntax::ast::Mutability; use rustc::mir::interpret::{ GlobalId, Value, Scalar, ScalarKind, - EvalError, EvalResult, EvalErrorKind, MemoryPointer, ConstValue, + EvalError, EvalResult, EvalErrorKind, Pointer, ConstValue, }; use std::mem; @@ -203,7 +203,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M r } - pub fn alloc_ptr(&mut self, ty: Ty<'tcx>) -> EvalResult<'tcx, MemoryPointer> { + pub fn alloc_ptr(&mut self, ty: Ty<'tcx>) -> EvalResult<'tcx, Pointer> { let layout = self.layout_of(ty)?; assert!(!layout.is_unsized(), "cannot alloc memory for unsized type"); @@ -245,7 +245,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M ConstValue::ByRef(alloc, offset) => { // FIXME: Allocate new AllocId for all constants inside let id = self.memory.allocate_value(alloc.clone(), Some(MemoryKind::Stack))?; - Ok(Value::ByRef(MemoryPointer::new(id, offset).into(), alloc.align)) + Ok(Value::ByRef(Pointer::new(id, offset).into(), alloc.align)) }, ConstValue::ScalarPair(a, b) => Ok(Value::ScalarPair(a, b)), ConstValue::Scalar(val) => Ok(Value::Scalar(val)), @@ -1019,7 +1019,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M .lock() .intern_static(gid.instance.def_id()); let layout = self.layout_of(ty)?; - let ptr = MemoryPointer::zero(alloc_id); + let ptr = Pointer::zero(alloc_id); return Ok(Value::ByRef(ptr.into(), layout.align)) } let cv = self.const_eval(gid)?; @@ -1329,7 +1329,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M pub(crate) fn read_ptr( &self, - ptr: MemoryPointer, + ptr: Pointer, ptr_align: Align, pointee_ty: Ty<'tcx>, ) -> EvalResult<'tcx, Value> { @@ -1358,7 +1358,7 @@ impl<'a, 'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M pub fn validate_ptr_target( &self, - ptr: MemoryPointer, + ptr: Pointer, ptr_align: Align, ty: Ty<'tcx> ) -> EvalResult<'tcx> { diff --git a/src/librustc_mir/interpret/machine.rs b/src/librustc_mir/interpret/machine.rs index 3054bbd1d77..4d04900320f 100644 --- a/src/librustc_mir/interpret/machine.rs +++ b/src/librustc_mir/interpret/machine.rs @@ -2,7 +2,7 @@ //! This separation exists to ensure that no fancy miri features like //! interpreting common C functions leak into CTFE. -use rustc::mir::interpret::{AllocId, EvalResult, Scalar, MemoryPointer, AccessKind, GlobalId}; +use rustc::mir::interpret::{AllocId, EvalResult, Scalar, Pointer, AccessKind, GlobalId}; use super::{EvalContext, Place, ValTy, Memory}; use rustc::mir; @@ -92,7 +92,7 @@ pub trait Machine<'mir, 'tcx>: Sized { fn check_locks<'a>( _mem: &Memory<'a, 'mir, 'tcx, Self>, - _ptr: MemoryPointer, + _ptr: Pointer, _size: Size, _access: AccessKind, ) -> EvalResult<'tcx> { diff --git a/src/librustc_mir/interpret/memory.rs b/src/librustc_mir/interpret/memory.rs index 2df722127bf..9278b08dff8 100644 --- a/src/librustc_mir/interpret/memory.rs +++ b/src/librustc_mir/interpret/memory.rs @@ -10,7 +10,7 @@ use syntax::ast::Mutability; use rustc::middle::const_val::{ConstVal, ErrKind}; use rustc_data_structures::fx::{FxHashSet, FxHashMap}; -use rustc::mir::interpret::{MemoryPointer, AllocId, Allocation, AccessKind, Value, +use rustc::mir::interpret::{Pointer, AllocId, Allocation, AccessKind, Value, EvalResult, Scalar, EvalErrorKind, GlobalId, AllocType}; pub use rustc::mir::interpret::{write_target_uint, write_target_int, read_target_uint}; @@ -71,14 +71,14 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { self.alloc_map.iter().map(|(&id, alloc)| (id, alloc)) } - pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> MemoryPointer { + pub fn create_fn_alloc(&mut self, instance: Instance<'tcx>) -> Pointer { let id = self.tcx.alloc_map.lock().create_fn_alloc(instance); - MemoryPointer::zero(id) + Pointer::zero(id) } - pub fn allocate_bytes(&mut self, bytes: &[u8]) -> MemoryPointer { + pub fn allocate_bytes(&mut self, bytes: &[u8]) -> Pointer { let id = self.tcx.allocate_bytes(bytes); - MemoryPointer::zero(id) + Pointer::zero(id) } /// kind is `None` for statics @@ -108,20 +108,20 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { size: Size, align: Align, kind: Option>, - ) -> EvalResult<'tcx, MemoryPointer> { + ) -> EvalResult<'tcx, Pointer> { let id = self.allocate_value(Allocation::undef(size, align), kind)?; - Ok(MemoryPointer::zero(id)) + Ok(Pointer::zero(id)) } pub fn reallocate( &mut self, - ptr: MemoryPointer, + ptr: Pointer, old_size: Size, old_align: Align, new_size: Size, new_align: Align, kind: MemoryKind, - ) -> EvalResult<'tcx, MemoryPointer> { + ) -> EvalResult<'tcx, Pointer> { if ptr.offset.bytes() != 0 { return err!(ReallocateNonBasePtr); } @@ -151,7 +151,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Ok(new_ptr) } - pub fn deallocate_local(&mut self, ptr: MemoryPointer) -> EvalResult<'tcx> { + pub fn deallocate_local(&mut self, ptr: Pointer) -> EvalResult<'tcx> { match self.alloc_kind.get(&ptr.alloc_id).cloned() { Some(MemoryKind::Stack) => self.deallocate(ptr, None, MemoryKind::Stack), // Happens if the memory was interned into immutable memory @@ -162,7 +162,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { pub fn deallocate( &mut self, - ptr: MemoryPointer, + ptr: Pointer, size_and_align: Option<(Size, Align)>, kind: MemoryKind, ) -> EvalResult<'tcx> { @@ -263,7 +263,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { } } - pub fn check_bounds(&self, ptr: MemoryPointer, access: bool) -> EvalResult<'tcx> { + pub fn check_bounds(&self, ptr: Pointer, access: bool) -> EvalResult<'tcx> { let alloc = self.get(ptr.alloc_id)?; let allocation_size = alloc.bytes.len() as u64; if ptr.offset.bytes() > allocation_size { @@ -351,7 +351,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { } } - pub fn get_fn(&self, ptr: MemoryPointer) -> EvalResult<'tcx, Instance<'tcx>> { + pub fn get_fn(&self, ptr: Pointer) -> EvalResult<'tcx, Instance<'tcx>> { if ptr.offset.bytes() != 0 { return err!(InvalidFunctionPointer); } @@ -479,7 +479,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { fn get_bytes_unchecked( &self, - ptr: MemoryPointer, + ptr: Pointer, size: Size, align: Align, ) -> EvalResult<'tcx, &[u8]> { @@ -499,7 +499,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { fn get_bytes_unchecked_mut( &mut self, - ptr: MemoryPointer, + ptr: Pointer, size: Size, align: Align, ) -> EvalResult<'tcx, &mut [u8]> { @@ -517,7 +517,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Ok(&mut alloc.bytes[offset..offset + size.bytes() as usize]) } - fn get_bytes(&self, ptr: MemoryPointer, size: Size, align: Align) -> EvalResult<'tcx, &[u8]> { + fn get_bytes(&self, ptr: Pointer, size: Size, align: Align) -> EvalResult<'tcx, &[u8]> { assert_ne!(size.bytes(), 0); if self.relocations(ptr, size)?.len() != 0 { return err!(ReadPointerAsBytes); @@ -528,7 +528,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { fn get_bytes_mut( &mut self, - ptr: MemoryPointer, + ptr: Pointer, size: Size, align: Align, ) -> EvalResult<'tcx, &mut [u8]> { @@ -653,7 +653,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Ok(()) } - pub fn read_c_str(&self, ptr: MemoryPointer) -> EvalResult<'tcx, &[u8]> { + pub fn read_c_str(&self, ptr: Pointer) -> EvalResult<'tcx, &[u8]> { let alloc = self.get(ptr.alloc_id)?; assert_eq!(ptr.offset.bytes() as usize as u64, ptr.offset.bytes()); let offset = ptr.offset.bytes() as usize; @@ -707,7 +707,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Ok(()) } - pub fn read_primval(&self, ptr: MemoryPointer, ptr_align: Align, size: Size) -> EvalResult<'tcx, Scalar> { + pub fn read_primval(&self, ptr: Pointer, ptr_align: Align, size: Size) -> EvalResult<'tcx, Scalar> { self.check_relocation_edges(ptr, size)?; // Make sure we don't read part of a pointer as a pointer let endianness = self.endianness(); let bytes = self.get_bytes_unchecked(ptr, size, ptr_align.min(self.int_align(size)))?; @@ -726,7 +726,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { } else { let alloc = self.get(ptr.alloc_id)?; match alloc.relocations.get(&ptr.offset) { - Some(&alloc_id) => return Ok(MemoryPointer::new(alloc_id, Size::from_bytes(bytes as u64)).into()), + Some(&alloc_id) => return Ok(Pointer::new(alloc_id, Size::from_bytes(bytes as u64)).into()), None => {}, } } @@ -734,7 +734,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Ok(Scalar::Bytes(bytes)) } - pub fn read_ptr_sized(&self, ptr: MemoryPointer, ptr_align: Align) -> EvalResult<'tcx, Scalar> { + pub fn read_ptr_sized(&self, ptr: Pointer, ptr_align: Align) -> EvalResult<'tcx, Scalar> { self.read_primval(ptr, ptr_align, self.pointer_size()) } @@ -782,7 +782,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Ok(()) } - pub fn write_ptr_sized_unsigned(&mut self, ptr: MemoryPointer, ptr_align: Align, val: Scalar) -> EvalResult<'tcx> { + pub fn write_ptr_sized_unsigned(&mut self, ptr: Pointer, ptr_align: Align, val: Scalar) -> EvalResult<'tcx> { let ptr_size = self.pointer_size(); self.write_primval(ptr.into(), ptr_align, val, ptr_size, false) } @@ -806,7 +806,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { fn relocations( &self, - ptr: MemoryPointer, + ptr: Pointer, size: Size, ) -> EvalResult<'tcx, &[(Size, AllocId)]> { let start = ptr.offset.bytes().saturating_sub(self.pointer_size().bytes() - 1); @@ -814,7 +814,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Ok(self.get(ptr.alloc_id)?.relocations.range(Size::from_bytes(start)..end)) } - fn clear_relocations(&mut self, ptr: MemoryPointer, size: Size) -> EvalResult<'tcx> { + fn clear_relocations(&mut self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { // Find the start and end of the given range and its outermost relocations. let (first, last) = { // Find all relocations overlapping the given range. @@ -846,7 +846,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Ok(()) } - fn check_relocation_edges(&self, ptr: MemoryPointer, size: Size) -> EvalResult<'tcx> { + fn check_relocation_edges(&self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { let overlapping_start = self.relocations(ptr, Size::ZERO)?.len(); let overlapping_end = self.relocations(ptr.offset(size, self)?, Size::ZERO)?.len(); if overlapping_start + overlapping_end != 0 { @@ -861,8 +861,8 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { // FIXME(solson): This is a very naive, slow version. fn copy_undef_mask( &mut self, - src: MemoryPointer, - dest: MemoryPointer, + src: Pointer, + dest: Pointer, size: Size, ) -> EvalResult<'tcx> { // The bits have to be saved locally before writing to dest in case src and dest overlap. @@ -882,7 +882,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> Memory<'a, 'mir, 'tcx, M> { Ok(()) } - fn check_defined(&self, ptr: MemoryPointer, size: Size) -> EvalResult<'tcx> { + fn check_defined(&self, ptr: Pointer, size: Size) -> EvalResult<'tcx> { let alloc = self.get(ptr.alloc_id)?; if !alloc.undef_mask.is_range_defined( ptr.offset, @@ -940,7 +940,7 @@ pub trait HasMemory<'a, 'mir, 'tcx: 'a + 'mir, M: Machine<'mir, 'tcx>> { fn into_ptr_vtable_pair( &self, value: Value, - ) -> EvalResult<'tcx, (Scalar, MemoryPointer)> { + ) -> EvalResult<'tcx, (Scalar, Pointer)> { match value { Value::ByRef(ref_ptr, align) => { let mem = self.memory(); diff --git a/src/librustc_mir/interpret/place.rs b/src/librustc_mir/interpret/place.rs index 7db53a2f59a..1c630491a9c 100644 --- a/src/librustc_mir/interpret/place.rs +++ b/src/librustc_mir/interpret/place.rs @@ -3,7 +3,7 @@ use rustc::ty::{self, Ty, TyCtxt}; use rustc::ty::layout::{self, Align, LayoutOf, TyLayout}; use rustc_data_structures::indexed_vec::Idx; -use rustc::mir::interpret::{GlobalId, Value, Scalar, EvalResult, MemoryPointer}; +use rustc::mir::interpret::{GlobalId, Value, Scalar, EvalResult, Pointer}; use super::{EvalContext, Machine, ValTy}; use interpret::memory::HasMemory; @@ -28,7 +28,7 @@ pub enum Place { pub enum PlaceExtra { None, Length(u64), - Vtable(MemoryPointer), + Vtable(Pointer), DowncastVariant(usize), } @@ -46,7 +46,7 @@ impl<'tcx> Place { } } - pub fn from_ptr(ptr: MemoryPointer, align: Align) -> Self { + pub fn from_ptr(ptr: Pointer, align: Align) -> Self { Self::from_primval_ptr(ptr.into(), align) } @@ -63,7 +63,7 @@ impl<'tcx> Place { (ptr, align) } - pub fn to_ptr(self) -> EvalResult<'tcx, MemoryPointer> { + pub fn to_ptr(self) -> EvalResult<'tcx, Pointer> { // At this point, we forget about the alignment information -- the place has been turned into a reference, // and no matter where it came from, it now must be aligned. self.to_ptr_align().0.to_ptr() @@ -210,7 +210,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { }; let alloc = Machine::init_static(self, cid)?; Place::Ptr { - ptr: MemoryPointer::zero(alloc).into(), + ptr: Pointer::zero(alloc).into(), align: layout.align, extra: PlaceExtra::None, } diff --git a/src/librustc_mir/interpret/traits.rs b/src/librustc_mir/interpret/traits.rs index 41dbffca78e..c94592cf159 100644 --- a/src/librustc_mir/interpret/traits.rs +++ b/src/librustc_mir/interpret/traits.rs @@ -2,7 +2,7 @@ use rustc::ty::{self, Ty}; use rustc::ty::layout::{Size, Align, LayoutOf}; use syntax::ast::Mutability; -use rustc::mir::interpret::{Scalar, Value, MemoryPointer, EvalResult}; +use rustc::mir::interpret::{Scalar, Value, Pointer, EvalResult}; use super::{EvalContext, Machine}; impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { @@ -16,7 +16,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { &mut self, ty: Ty<'tcx>, trait_ref: ty::PolyTraitRef<'tcx>, - ) -> EvalResult<'tcx, MemoryPointer> { + ) -> EvalResult<'tcx, Pointer> { debug!("get_vtable(trait_ref={:?})", trait_ref); let layout = self.layout_of(trait_ref.self_ty())?; @@ -61,7 +61,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { pub fn read_drop_type_from_vtable( &self, - vtable: MemoryPointer, + vtable: Pointer, ) -> EvalResult<'tcx, Option>> { // we don't care about the pointee type, we just want a pointer let pointer_align = self.tcx.data_layout.pointer_align; @@ -75,7 +75,7 @@ impl<'a, 'mir, 'tcx, M: Machine<'mir, 'tcx>> EvalContext<'a, 'mir, 'tcx, M> { pub fn read_size_and_align_from_vtable( &self, - vtable: MemoryPointer, + vtable: Pointer, ) -> EvalResult<'tcx, (Size, Align)> { let pointer_size = self.memory.pointer_size(); let pointer_align = self.tcx.data_layout.pointer_align;