diff options
Diffstat (limited to 'compiler/rustc_middle/src/mir/interpret/pointer.rs')
| -rw-r--r-- | compiler/rustc_middle/src/mir/interpret/pointer.rs | 10 |
1 files changed, 6 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/pointer.rs b/compiler/rustc_middle/src/mir/interpret/pointer.rs index c71aea417ec..26da93b9dce 100644 --- a/compiler/rustc_middle/src/mir/interpret/pointer.rs +++ b/compiler/rustc_middle/src/mir/interpret/pointer.rs @@ -120,9 +120,11 @@ pub trait Provenance: Copy + fmt::Debug { where Self: Sized; - /// Provenance must always be able to identify the allocation this ptr points to. + /// If `OFFSET_IS_ADDR == false`, provenance must always be able to + /// identify the allocation this ptr points to (i.e., this must return `Some`). + /// Otherwise this function is best-effort (but must agree with `Machine::ptr_get_alloc`). /// (Identifying the offset in that allocation, however, is harder -- use `Memory::ptr_get_alloc` for that.) - fn get_alloc_id(self) -> AllocId; + fn get_alloc_id(self) -> Option<AllocId>; } impl Provenance for AllocId { @@ -147,8 +149,8 @@ impl Provenance for AllocId { Ok(()) } - fn get_alloc_id(self) -> AllocId { - self + fn get_alloc_id(self) -> Option<AllocId> { + Some(self) } } |
