Ok(b as u64)
}
- pub fn to_usize(self, cx: &impl HasDataLayout) -> InterpResult<'static, u64> {
+ pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'static, u64> {
let b = self.to_bits(cx.data_layout().pointer_size)?;
Ok(b as u64)
}
Ok(b as i64)
}
- pub fn to_isize(self, cx: &impl HasDataLayout) -> InterpResult<'static, i64> {
+ pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'static, i64> {
let sz = cx.data_layout().pointer_size;
let b = self.to_bits(sz)?;
let b = sign_extend(b, sz) as i128;
}
#[inline(always)]
- pub fn to_usize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> {
- self.not_undef()?.to_usize(cx)
+ pub fn to_machine_usize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, u64> {
+ self.not_undef()?.to_machine_usize(cx)
}
#[inline(always)]
}
#[inline(always)]
- pub fn to_isize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, i64> {
- self.not_undef()?.to_isize(cx)
+ pub fn to_machine_isize(self, cx: &impl HasDataLayout) -> InterpResult<'tcx, i64> {
+ self.not_undef()?.to_machine_isize(cx)
}
}
0,
),
};
- let len = b.to_usize(&ecx.tcx.tcx).unwrap();
+ let len = b.to_machine_usize(&ecx.tcx.tcx).unwrap();
let start = start.try_into().unwrap();
let len: usize = len.try_into().unwrap();
ConstValue::Slice {
}
ty::Slice(_) | ty::Str => {
- let len = metadata.expect("slice fat ptr must have vtable").to_usize(self)?;
+ let len = metadata.expect("slice fat ptr must have length").to_machine_usize(self)?;
let elem = layout.field(self, 0)?;
// Make sure the slice is not too big.
ty::Array(_, n)
if n.eval_usize(self.ecx.tcx.tcx, self.ecx.param_env) == 0 => {}
ty::Slice(_)
- if mplace.meta.unwrap().to_usize(self.ecx)? == 0 => {}
+ if mplace.meta.unwrap().to_machine_usize(self.ecx)? == 0 => {}
_ => bug!("const qualif failed to prevent mutable references"),
}
},
// This is the dual to the special exception for offset-by-0
// in the inbounds pointer offset operation (see the Miri code, `src/operator.rs`).
if a.is_bits() && b.is_bits() {
- let a = a.to_usize(self)?;
- let b = b.to_usize(self)?;
+ let a = a.to_machine_usize(self)?;
+ let b = b.to_machine_usize(self)?;
if a == b && a != 0 {
self.write_scalar(Scalar::from_int(0, isize_layout.size), dest)?;
return Ok(true);
) -> InterpResult<'tcx, Pointer<M::PointerTag>> {
match scalar {
Scalar::Ptr(ptr) => Ok(ptr),
- _ => M::int_to_ptr(&self, scalar.to_usize(self)?)
+ _ => M::int_to_ptr(&self, scalar.to_machine_usize(self)?)
}
}
// We need to consult `meta` metadata
match self.layout.ty.kind {
ty::Slice(..) | ty::Str =>
- return self.mplace.meta.unwrap().to_usize(cx),
+ return self.mplace.meta.unwrap().to_machine_usize(cx),
_ => bug!("len not supported on unsized type {:?}", self.layout.ty),
}
} else {
// FIXME: More checks for the vtable.
}
ty::Slice(..) | ty::Str => {
- let _len = try_validation!(meta.unwrap().to_usize(self.ecx),
+ let _len = try_validation!(meta.unwrap().to_machine_usize(self.ecx),
"non-integer slice length in wide pointer", self.path);
// We do not check that `len * elem_size <= isize::MAX`:
// that is only required for references, and there it falls out of the