about summary refs log tree commit diff
path: root/compiler/rustc_middle/src/mir/interpret/pointer.rs
diff options
context:
space:
mode:
authorRalf Jung <post@ralfj.de>2022-08-27 14:54:02 -0400
committerRalf Jung <post@ralfj.de>2022-08-27 18:37:44 -0400
commit2e172473daefd24631faf3906bd411798d7d8a17 (patch)
tree4bbfce7ca26338ca0db6ac3821acafd58b479d5c /compiler/rustc_middle/src/mir/interpret/pointer.rs
parente63a6257118effd270223ae38306013dfd477516 (diff)
downloadrust-2e172473daefd24631faf3906bd411798d7d8a17.tar.gz
rust-2e172473daefd24631faf3906bd411798d7d8a17.zip
interpret: make read-pointer-as-bytes *always* work in Miri
and show some extra information when it happens in CTFE
Diffstat (limited to 'compiler/rustc_middle/src/mir/interpret/pointer.rs')
-rw-r--r--compiler/rustc_middle/src/mir/interpret/pointer.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/compiler/rustc_middle/src/mir/interpret/pointer.rs b/compiler/rustc_middle/src/mir/interpret/pointer.rs
index 384954cbbd5..5fa802236ed 100644
--- a/compiler/rustc_middle/src/mir/interpret/pointer.rs
+++ b/compiler/rustc_middle/src/mir/interpret/pointer.rs
@@ -125,6 +125,9 @@ pub trait Provenance: Copy + fmt::Debug {
     /// 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) -> Option<AllocId>;
+
+    /// Defines the 'join' of provenance: what happens when doing a pointer load and different bytes have different provenance.
+    fn join(left: Option<Self>, right: Option<Self>) -> Option<Self>;
 }
 
 impl Provenance for AllocId {
@@ -152,6 +155,10 @@ impl Provenance for AllocId {
     fn get_alloc_id(self) -> Option<AllocId> {
         Some(self)
     }
+
+    fn join(_left: Option<Self>, _right: Option<Self>) -> Option<Self> {
+        panic!("merging provenance is not supported when `OFFSET_IS_ADDR` is false")
+    }
 }
 
 /// Represents a pointer in the Miri engine.