diff options
| author | Ralf Jung <post@ralfj.de> | 2017-07-28 19:43:05 -0700 |
|---|---|---|
| committer | Ralf Jung <post@ralfj.de> | 2017-07-28 19:43:05 -0700 |
| commit | eb6c743e424ec9ebe80ad7026175d506e6b6da65 (patch) | |
| tree | 3d622d8eb5d780ea23a174daceab9a1bf124012a /src | |
| parent | 14c8e834b99ca3d422828b44ed0b2d4a76335be6 (diff) | |
| download | rust-eb6c743e424ec9ebe80ad7026175d506e6b6da65.tar.gz rust-eb6c743e424ec9ebe80ad7026175d506e6b6da65.zip | |
avoid anonymous bool
Diffstat (limited to 'src')
| -rw-r--r-- | src/librustc_mir/interpret/eval_context.rs | 75 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/lvalue.rs | 6 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/step.rs | 4 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/terminator/intrinsic.rs | 14 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/terminator/mod.rs | 10 | ||||
| -rw-r--r-- | src/librustc_mir/interpret/value.rs | 10 |
6 files changed, 62 insertions, 57 deletions
diff --git a/src/librustc_mir/interpret/eval_context.rs b/src/librustc_mir/interpret/eval_context.rs index c1ddfb9ffea..bbaaba08a14 100644 --- a/src/librustc_mir/interpret/eval_context.rs +++ b/src/librustc_mir/interpret/eval_context.rs @@ -142,6 +142,12 @@ impl Default for ResourceLimits { } } +#[derive(Copy, Clone, Debug)] +pub struct TyAndPacked<'tcx> { + pub ty: Ty<'tcx>, + pub packed: bool, +} + impl<'a, 'tcx> EvalContext<'a, 'tcx> { pub fn new(tcx: TyCtxt<'a, 'tcx, 'tcx>, limits: ResourceLimits) -> Self { EvalContext { @@ -381,7 +387,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { .expect("global should have been cached (static)"); match global_value.value { // FIXME: to_ptr()? might be too extreme here, static zsts might reach this under certain conditions - Value::ByRef(ptr, _aligned) => + Value::ByRef { ptr, aligned: _aligned } => // Alignment does not matter for this call self.memory.mark_static_initalized(ptr.to_ptr()?.alloc_id, mutable)?, Value::ByVal(val) => if let PrimVal::Ptr(ptr) = val { @@ -439,7 +445,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } pub fn deallocate_local(&mut self, local: Option<Value>) -> EvalResult<'tcx> { - if let Some(Value::ByRef(ptr, _aligned)) = local { + if let Some(Value::ByRef { ptr, aligned: _ }) = local { trace!("deallocating local"); let ptr = ptr.to_ptr()?; self.memory.dump_alloc(ptr.alloc_id); @@ -609,7 +615,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let operand_ty = self.operand_ty(operand); assert_eq!(self.type_size(operand_ty)?, Some(0)); } - let (offset, ty, _packed) = self.nonnull_offset_and_ty(dest_ty, nndiscr, discrfield)?; + let (offset, TyAndPacked { ty, packed: _}) = self.nonnull_offset_and_ty(dest_ty, nndiscr, discrfield)?; // TODO: The packed flag is ignored // FIXME(solson) @@ -745,7 +751,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let src_ty = self.operand_ty(operand); if self.type_is_fat_ptr(src_ty) { match (src, self.type_is_fat_ptr(dest_ty)) { - (Value::ByRef(..), _) | + (Value::ByRef{..}, _) | (Value::ByValPair(..), true) => { self.write_value(src, dest, dest_ty)?; }, @@ -826,7 +832,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { ty: Ty<'tcx>, nndiscr: u64, discrfield: &[u32], - ) -> EvalResult<'tcx, (Size, Ty<'tcx>, bool)> { + ) -> EvalResult<'tcx, (Size, TyAndPacked<'tcx>)> { // Skip the constant 0 at the start meant for LLVM GEP and the outer non-null variant let path = discrfield.iter().skip(2).map(|&i| i as usize); @@ -849,19 +855,19 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { mut offset: Size, mut ty: Ty<'tcx>, path: I, - ) -> EvalResult<'tcx, (Size, Ty<'tcx>, bool)> { + ) -> EvalResult<'tcx, (Size, TyAndPacked<'tcx>)> { // Skip the initial 0 intended for LLVM GEP. let mut packed = false; for field_index in path { let field_offset = self.get_field_offset(ty, field_index)?; trace!("field_path_offset_and_ty: {}, {}, {:?}, {:?}", field_index, ty, field_offset, offset); let field_ty = self.get_field_ty(ty, field_index)?; - ty = field_ty.0; - packed = packed || field_ty.1; + ty = field_ty.ty; + packed = packed || field_ty.packed; offset = offset.checked_add(field_offset, &self.tcx.data_layout).unwrap(); } - Ok((offset, ty, packed)) + Ok((offset, TyAndPacked { ty, packed })) } fn get_fat_field(&self, pointee_ty: Ty<'tcx>, field_index: usize) -> EvalResult<'tcx, Ty<'tcx>> { match (field_index, &self.tcx.struct_tail(pointee_ty).sty) { @@ -874,18 +880,18 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } /// Returns the field type and whether the field is packed - pub fn get_field_ty(&self, ty: Ty<'tcx>, field_index: usize) -> EvalResult<'tcx, (Ty<'tcx>, bool)> { + pub fn get_field_ty(&self, ty: Ty<'tcx>, field_index: usize) -> EvalResult<'tcx, TyAndPacked<'tcx>> { match ty.sty { ty::TyAdt(adt_def, _) if adt_def.is_box() => - Ok((self.get_fat_field(ty.boxed_ty(), field_index)?, false)), + Ok(TyAndPacked { ty: self.get_fat_field(ty.boxed_ty(), field_index)?, packed: false }), ty::TyAdt(adt_def, substs) if adt_def.is_enum() => { use rustc::ty::layout::Layout::*; match *self.type_layout(ty)? { RawNullablePointer { nndiscr, .. } => - Ok((adt_def.variants[nndiscr as usize].fields[field_index].ty(self.tcx, substs), false)), + Ok(TyAndPacked { ty: adt_def.variants[nndiscr as usize].fields[field_index].ty(self.tcx, substs), packed: false }), StructWrappedNullablePointer { nndiscr, ref nonnull, .. } => { let ty = adt_def.variants[nndiscr as usize].fields[field_index].ty(self.tcx, substs); - Ok((ty, nonnull.packed)) + Ok(TyAndPacked { ty, packed: nonnull.packed }) }, _ => Err(EvalError::Unimplemented(format!("get_field_ty can't handle enum type: {:?}, {:?}", ty, ty.sty))), } @@ -895,17 +901,17 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { use rustc::ty::layout::Layout::*; match *self.type_layout(ty)? { Univariant { ref variant, .. } => - Ok((variant_def.fields[field_index].ty(self.tcx, substs), variant.packed)), + Ok(TyAndPacked { ty: variant_def.fields[field_index].ty(self.tcx, substs), packed: variant.packed }), _ => Err(EvalError::Unimplemented(format!("get_field_ty can't handle struct type: {:?}, {:?}", ty, ty.sty))), } } - ty::TyTuple(fields, _) => Ok((fields[field_index], false)), + ty::TyTuple(fields, _) => Ok(TyAndPacked { ty: fields[field_index], packed: false }), ty::TyRef(_, ref tam) | - ty::TyRawPtr(ref tam) => Ok((self.get_fat_field(tam.ty, field_index)?, false)), + ty::TyRawPtr(ref tam) => Ok(TyAndPacked { ty: self.get_fat_field(tam.ty, field_index)?, packed: false }), - ty::TyArray(ref inner, _) => Ok((inner, false)), + ty::TyArray(ref inner, _) => Ok(TyAndPacked { ty: inner, packed: false }), _ => Err(EvalError::Unimplemented(format!("can't handle type: {:?}, {:?}", ty, ty.sty))), } @@ -1042,7 +1048,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { // -1 since we don't store the return value match self.stack[frame].locals[local.index() - 1] { None => return Err(EvalError::DeadLocal), - Some(Value::ByRef(ptr, aligned)) => { + Some(Value::ByRef { ptr, aligned }) => { Lvalue::Ptr { ptr, aligned, extra: LvalueExtra::None } }, Some(val) => { @@ -1060,7 +1066,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { Lvalue::Global(cid) => { let global_val = self.globals.get(&cid).expect("global not cached").clone(); match global_val.value { - Value::ByRef(ptr, aligned) => + Value::ByRef { ptr, aligned } => Lvalue::Ptr { ptr, aligned, extra: LvalueExtra::None }, _ => { let ptr = self.alloc_ptr_with_substs(global_val.ty, cid.instance.substs)?; @@ -1086,7 +1092,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { /// ensures this Value is not a ByRef pub(super) fn follow_by_ref_value(&mut self, value: Value, ty: Ty<'tcx>) -> EvalResult<'tcx, Value> { match value { - Value::ByRef(ptr, aligned) => { + Value::ByRef { ptr, aligned } => { self.read_maybe_aligned(aligned, |ectx| ectx.read_value(ptr, ty)) } other => Ok(other), @@ -1095,7 +1101,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { pub(super) fn value_to_primval(&mut self, value: Value, ty: Ty<'tcx>) -> EvalResult<'tcx, PrimVal> { match self.follow_by_ref_value(value, ty)? { - Value::ByRef(..) => bug!("follow_by_ref_value can't result in `ByRef`"), + Value::ByRef{..} => bug!("follow_by_ref_value can't result in `ByRef`"), Value::ByVal(primval) => { self.ensure_valid_value(primval, ty)?; @@ -1185,7 +1191,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { old_dest_val: Value, dest_ty: Ty<'tcx>, ) -> EvalResult<'tcx> { - if let Value::ByRef(dest_ptr, aligned) = old_dest_val { + if let Value::ByRef { ptr: dest_ptr, aligned } = old_dest_val { // If the value is already `ByRef` (that is, backed by an `Allocation`), // then we must write the new value into this allocation, because there may be // other pointers into the allocation. These other pointers are logically @@ -1196,7 +1202,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { self.write_maybe_aligned_mut(aligned, |ectx| ectx.write_value_to_ptr(src_val, dest_ptr, dest_ty))?; - } else if let Value::ByRef(src_ptr, aligned) = src_val { + } else if let Value::ByRef { ptr: src_ptr, aligned } = src_val { // If the value is not `ByRef`, then we know there are no pointers to it // and we can simply overwrite the `Value` in the locals array directly. // @@ -1234,7 +1240,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { dest_ty: Ty<'tcx>, ) -> EvalResult<'tcx> { match value { - Value::ByRef(ptr, aligned) => { + Value::ByRef { ptr, aligned } => { self.read_maybe_aligned_mut(aligned, |ectx| ectx.copy(ptr, dest, dest_ty)) }, Value::ByVal(primval) => { @@ -1255,19 +1261,18 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let mut packed = false; while self.get_field_count(ty)? == 1 { let field = self.get_field_ty(ty, 0)?; - ty = field.0; - packed = packed || field.1; + ty = field.ty; + packed = packed || field.packed; } assert_eq!(self.get_field_count(ty)?, 2); let field_0 = self.get_field_offset(ty, 0)?; let field_1 = self.get_field_offset(ty, 1)?; let field_0_ty = self.get_field_ty(ty, 0)?; let field_1_ty = self.get_field_ty(ty, 1)?; - // The .1 components say whether the field is packed - assert_eq!(field_0_ty.1, field_1_ty.1, "the two fields must agree on being packed"); - packed = packed || field_0_ty.1; - let field_0_size = self.type_size(field_0_ty.0)?.expect("pair element type must be sized"); - let field_1_size = self.type_size(field_1_ty.0)?.expect("pair element type must be sized"); + assert_eq!(field_0_ty.packed, field_1_ty.packed, "the two fields must agree on being packed"); + packed = packed || field_0_ty.packed; + let field_0_size = self.type_size(field_0_ty.ty)?.expect("pair element type must be sized"); + let field_1_size = self.type_size(field_1_ty.ty)?.expect("pair element type must be sized"); let field_0_ptr = ptr.offset(field_0.bytes(), &self)?.into(); let field_1_ptr = ptr.offset(field_1.bytes(), &self)?.into(); self.write_maybe_aligned_mut(!packed, @@ -1554,8 +1559,8 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } if self.ty_to_primval_kind(src_ty).is_ok() { // TODO: We ignore the packed flag here - let sty = self.get_field_ty(src_ty, 0)?.0; - let dty = self.get_field_ty(dest_ty, 0)?.0; + let sty = self.get_field_ty(src_ty, 0)?.ty; + let dty = self.get_field_ty(dest_ty, 0)?.ty; return self.unsize_into(src, sty, dest, dty); } // unsizing of generic struct with pointer fields @@ -1570,7 +1575,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { //let src = adt::MaybeSizedValue::sized(src); //let dst = adt::MaybeSizedValue::sized(dst); let src_ptr = match src { - Value::ByRef(ptr, true) => ptr, + Value::ByRef { ptr, aligned: true } => ptr, // TODO: Is it possible for unaligned pointers to occur here? _ => bug!("expected aligned pointer, got {:?}", src), }; @@ -1617,7 +1622,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { Err(err) => { panic!("Failed to access local: {:?}", err); } - Ok(Value::ByRef(ptr, aligned)) => match ptr.into_inner_primval() { + Ok(Value::ByRef { ptr, aligned }) => match ptr.into_inner_primval() { PrimVal::Ptr(ptr) => { write!(msg, " by {}ref:", if aligned { "" } else { "unaligned " }).unwrap(); allocs.push(ptr.alloc_id); diff --git a/src/librustc_mir/interpret/lvalue.rs b/src/librustc_mir/interpret/lvalue.rs index 4d4db267ecf..f1d1ba70b4f 100644 --- a/src/librustc_mir/interpret/lvalue.rs +++ b/src/librustc_mir/interpret/lvalue.rs @@ -196,7 +196,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { match lvalue { Lvalue::Ptr { ptr, extra, aligned } => { assert_eq!(extra, LvalueExtra::None); - Ok(Value::ByRef(ptr, aligned)) + Ok(Value::ByRef { ptr, aligned }) } Lvalue::Local { frame, local } => { self.stack[frame].get_local(local) @@ -307,7 +307,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { assert_eq!(offset.bytes(), 0, "ByVal can only have 1 non zst field with offset 0"); return Ok(base); }, - Value::ByRef(..) | + Value::ByRef{..} | Value::ByValPair(..) | Value::ByVal(_) => self.force_allocation(base)?.to_ptr_extra_aligned(), }, @@ -317,7 +317,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { assert_eq!(offset.bytes(), 0, "ByVal can only have 1 non zst field with offset 0"); return Ok(base); }, - Value::ByRef(..) | + Value::ByRef{..} | Value::ByValPair(..) | Value::ByVal(_) => self.force_allocation(base)?.to_ptr_extra_aligned(), }, diff --git a/src/librustc_mir/interpret/step.rs b/src/librustc_mir/interpret/step.rs index b78945155f1..1679688625d 100644 --- a/src/librustc_mir/interpret/step.rs +++ b/src/librustc_mir/interpret/step.rs @@ -15,7 +15,7 @@ use syntax::codemap::Span; use syntax::ast::Mutability; use error::{EvalResult, EvalError}; -use eval_context::{EvalContext, StackPopCleanup}; +use eval_context::{EvalContext, StackPopCleanup, TyAndPacked}; use lvalue::{Global, GlobalId, Lvalue}; use value::{Value, PrimVal}; use memory::HasMemory; @@ -103,7 +103,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { Layout::StructWrappedNullablePointer { nndiscr, ref discrfield, .. } => { if variant_index as u64 != nndiscr { - let (offset, ty, packed) = self.nonnull_offset_and_ty(dest_ty, nndiscr, discrfield)?; + let (offset, TyAndPacked { ty, packed }) = self.nonnull_offset_and_ty(dest_ty, nndiscr, discrfield)?; let nonnull = self.force_allocation(dest)?.to_ptr()?.offset(offset.bytes(), &self)?; trace!("struct wrapped nullable pointer type: {}", ty); // only the pointer part of a fat pointer is used for this space optimization diff --git a/src/librustc_mir/interpret/terminator/intrinsic.rs b/src/librustc_mir/interpret/terminator/intrinsic.rs index 69dd41c82aa..5c608bc1630 100644 --- a/src/librustc_mir/interpret/terminator/intrinsic.rs +++ b/src/librustc_mir/interpret/terminator/intrinsic.rs @@ -85,7 +85,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let old = self.read_value(ptr, ty)?; let old = match old { Value::ByVal(val) => val, - Value::ByRef(..) => bug!("just read the value, can't be byref"), + Value::ByRef { .. } => bug!("just read the value, can't be byref"), Value::ByValPair(..) => bug!("atomic_xchg doesn't work with nonprimitives"), }; self.write_primval(dest, old, ty)?; @@ -100,7 +100,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let old = self.read_value(ptr, ty)?; let old = match old { Value::ByVal(val) => val, - Value::ByRef(..) => bug!("just read the value, can't be byref"), + Value::ByRef { .. } => bug!("just read the value, can't be byref"), Value::ByValPair(..) => bug!("atomic_cxchg doesn't work with nonprimitives"), }; let (val, _) = self.binary_op(mir::BinOp::Eq, old, ty, expect_old, ty)?; @@ -120,7 +120,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let old = self.read_value(ptr, ty)?; let old = match old { Value::ByVal(val) => val, - Value::ByRef(..) => bug!("just read the value, can't be byref"), + Value::ByRef { .. } => bug!("just read the value, can't be byref"), Value::ByValPair(..) => bug!("atomic_xadd_relaxed doesn't work with nonprimitives"), }; self.write_primval(dest, old, ty)?; @@ -251,10 +251,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let size = self.type_size(dest_ty)?.expect("cannot zero unsized value"); let init = |this: &mut Self, val: Value| { let zero_val = match val { - Value::ByRef(ptr, aligned) => { + Value::ByRef { ptr, aligned } => { // These writes have no alignment restriction anyway. this.memory.write_repeat(ptr, 0, size)?; - Value::ByRef(ptr, aligned) + Value::ByRef { ptr, aligned } }, // TODO(solson): Revisit this, it's fishy to check for Undef here. Value::ByVal(PrimVal::Undef) => match this.ty_to_primval_kind(dest_ty) { @@ -442,9 +442,9 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let size = dest_layout.size(&self.tcx.data_layout).bytes(); let uninit = |this: &mut Self, val: Value| { match val { - Value::ByRef(ptr, aligned) => { + Value::ByRef { ptr, aligned } => { this.memory.mark_definedness(ptr, size, false)?; - Ok(Value::ByRef(ptr, aligned)) + Ok(Value::ByRef { ptr, aligned }) }, _ => Ok(Value::ByVal(PrimVal::Undef)), } diff --git a/src/librustc_mir/interpret/terminator/mod.rs b/src/librustc_mir/interpret/terminator/mod.rs index b9b72ca34ac..288409783db 100644 --- a/src/librustc_mir/interpret/terminator/mod.rs +++ b/src/librustc_mir/interpret/terminator/mod.rs @@ -7,7 +7,7 @@ use syntax::attr; use syntax::abi::Abi; use error::{EvalError, EvalResult}; -use eval_context::{EvalContext, IntegerExt, StackPopCleanup, is_inhabited, self}; +use eval_context::{EvalContext, IntegerExt, StackPopCleanup, TyAndPacked, is_inhabited, self}; use lvalue::Lvalue; use memory::{MemoryPointer, TlsKey, Kind, HasMemory}; use value::{PrimVal, Value}; @@ -313,10 +313,10 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { if self.frame().mir.args_iter().count() == fields.len() + 1 { let offsets = variant.offsets.iter().map(|s| s.bytes()); match arg_val { - Value::ByRef(ptr, aligned) => { + Value::ByRef { ptr, aligned } => { assert!(aligned, "Unaligned ByRef-values cannot occur as function arguments"); for ((offset, ty), arg_local) in offsets.zip(fields).zip(arg_locals) { - let arg = Value::ByRef(ptr.offset(offset, &self)?, true); + let arg = Value::ByRef { ptr: ptr.offset(offset, &self)?, aligned: true}; let dest = self.eval_lvalue(&mir::Lvalue::Local(arg_local))?; trace!("writing arg {:?} to {:?} (type: {})", arg, dest, ty); self.write_value(arg, dest, ty)?; @@ -402,7 +402,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { let instance = self.memory.get_fn(fn_ptr.to_ptr()?)?; let mut arg_operands = arg_operands.to_vec(); let ty = self.operand_ty(&arg_operands[0]); - let ty = self.get_field_ty(ty, 0)?.0; // TODO: packed flag is ignored + let ty = self.get_field_ty(ty, 0)?.ty; // TODO: packed flag is ignored match arg_operands[0] { mir::Operand::Consume(ref mut lval) => *lval = lval.clone().field(mir::Field::new(0), ty), _ => bug!("virtual call first arg cannot be a constant"), @@ -487,7 +487,7 @@ impl<'a, 'tcx> EvalContext<'a, 'tcx> { } StructWrappedNullablePointer { nndiscr, ref discrfield, .. } => { - let (offset, ty, packed) = self.nonnull_offset_and_ty(adt_ty, nndiscr, discrfield)?; + let (offset, TyAndPacked { ty, packed }) = self.nonnull_offset_and_ty(adt_ty, nndiscr, discrfield)?; let nonnull = adt_ptr.offset(offset.bytes(), &*self)?; trace!("struct wrapped nullable pointer type: {}", ty); // only the pointer part of a fat pointer is used for this space optimization diff --git a/src/librustc_mir/interpret/value.rs b/src/librustc_mir/interpret/value.rs index 302ea0abec3..87b3d9f383c 100644 --- a/src/librustc_mir/interpret/value.rs +++ b/src/librustc_mir/interpret/value.rs @@ -32,7 +32,7 @@ pub(super) fn f64_to_bytes(f: f64) -> u128 { /// operations and fat pointers. This idea was taken from rustc's trans. #[derive(Clone, Copy, Debug)] pub enum Value { - ByRef(Pointer, bool), + ByRef { ptr: Pointer, aligned: bool}, ByVal(PrimVal), ByValPair(PrimVal, PrimVal), } @@ -162,7 +162,7 @@ pub enum PrimValKind { impl<'a, 'tcx: 'a> Value { #[inline] pub(super) fn by_ref(ptr: Pointer) -> Self { - Value::ByRef(ptr, true) + Value::ByRef { ptr, aligned: true } } /// Convert the value into a pointer (or a pointer-sized integer). If the value is a ByRef, @@ -170,7 +170,7 @@ impl<'a, 'tcx: 'a> Value { pub(super) fn into_ptr(&self, mem: &Memory<'a, 'tcx>) -> EvalResult<'tcx, Pointer> { use self::Value::*; match *self { - ByRef(ptr, aligned) => { + ByRef { ptr, aligned } => { mem.read_maybe_aligned(aligned, |mem| mem.read_ptr(ptr.to_ptr()?) ) }, ByVal(ptr) | ByValPair(ptr, _) => Ok(ptr.into()), @@ -183,7 +183,7 @@ impl<'a, 'tcx: 'a> Value { ) -> EvalResult<'tcx, (Pointer, MemoryPointer)> { use self::Value::*; match *self { - ByRef(ref_ptr, aligned) => { + ByRef { ptr: ref_ptr, aligned } => { mem.read_maybe_aligned(aligned, |mem| { let ptr = mem.read_ptr(ref_ptr.to_ptr()?)?; let vtable = mem.read_ptr(ref_ptr.offset(mem.pointer_size(), mem.layout)?.to_ptr()?)?; @@ -200,7 +200,7 @@ impl<'a, 'tcx: 'a> Value { pub(super) fn into_slice(&self, mem: &Memory<'a, 'tcx>) -> EvalResult<'tcx, (Pointer, u64)> { use self::Value::*; match *self { - ByRef(ref_ptr, aligned) => { + ByRef { ptr: ref_ptr, aligned } => { mem.read_maybe_aligned(aligned, |mem| { let ptr = mem.read_ptr(ref_ptr.to_ptr()?)?; let len = mem.read_usize(ref_ptr.offset(mem.pointer_size(), mem.layout)?.to_ptr()?)?; |
