1
Fork 0

adjustions and cleanup to make Miri build again

This commit is contained in:
Ralf Jung 2021-07-14 22:10:17 +02:00
parent 8932aebfdf
commit f4b61ba509
13 changed files with 134 additions and 201 deletions

View file

@ -171,7 +171,7 @@ impl<Tag> From<Pointer<Tag>> for Pointer<Option<Tag>> {
}
impl<Tag> Pointer<Option<Tag>> {
pub fn into_pointer_or_offset(self) -> Result<Pointer<Tag>, Size> {
pub fn into_pointer_or_addr(self) -> Result<Pointer<Tag>, Size> {
match self.provenance {
Some(tag) => Ok(Pointer::new(tag, self.offset)),
None => Err(self.offset),
@ -187,6 +187,13 @@ impl<Tag> Pointer<Option<Tag>> {
}
}
impl<Tag> Pointer<Option<Tag>> {
#[inline(always)]
pub fn null() -> Self {
Pointer { provenance: None, offset: Size::ZERO }
}
}
impl<'tcx, Tag> Pointer<Tag> {
#[inline(always)]
pub fn new(provenance: Tag, offset: Size) -> Self {
@ -206,9 +213,14 @@ impl<'tcx, Tag> Pointer<Tag> {
where
Tag: Provenance,
{
// FIXME: This is wrong! `self.offset` might be an absolute address.
Pointer { offset: self.offset, provenance: self.provenance.erase_for_fmt() }
}
pub fn map_provenance(self, f: impl FnOnce(Tag) -> Tag) -> Self {
Pointer { provenance: f(self.provenance), ..self }
}
#[inline]
pub fn offset(self, i: Size, cx: &impl HasDataLayout) -> InterpResult<'tcx, Self> {
Ok(Pointer {