about summary refs log tree commit diff
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2022-08-27 19:56:35 +0000
committerbors <bors@rust-lang.org>2022-08-27 19:56:35 +0000
commit12907ab4d7aa155aa24600ddba3742d8aaaeba8a (patch)
tree046e2eb94a78c958e17a392715b6b95aaa1842ce
parentbb8212484f848439fc61b1f2d50de2444459da59 (diff)
parentb4eff16e0c943ef8250c0d49e1bc5501ee11467b (diff)
downloadrust-12907ab4d7aa155aa24600ddba3742d8aaaeba8a.tar.gz
rust-12907ab4d7aa155aa24600ddba3742d8aaaeba8a.zip
Auto merge of #2514 - RalfJung:dont-compare, r=RalfJung
ensure we don't compare provenance

Comparing provenance is meaningless, since `Wildcard` might be any provenance.
-rw-r--r--src/machine.rs20
1 files changed, 19 insertions, 1 deletions
diff --git a/src/machine.rs b/src/machine.rs
index 6bba5bcc5f0..0862b3b17c6 100644
--- a/src/machine.rs
+++ b/src/machine.rs
@@ -126,7 +126,7 @@ impl fmt::Display for MiriMemoryKind {
 }
 
 /// Pointer provenance.
-#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
+#[derive(Debug, Clone, Copy)]
 pub enum Provenance {
     Concrete {
         alloc_id: AllocId,
@@ -136,6 +136,24 @@ pub enum Provenance {
     Wildcard,
 }
 
+// This needs to be `Eq`+`Hash` because the `Machine` trait needs that because validity checking
+// *might* be recursive and then it has to track which places have already been visited.
+// However, comparing provenance is meaningless, since `Wildcard` might be any provenance -- and of
+// course we don't actually do recursive checking.
+// We could change `RefTracking` to strip provenance for its `seen` set but that type is generic so that is quite annoying.
+// Instead owe add the required instances but make them panic.
+impl PartialEq for Provenance {
+    fn eq(&self, _other: &Self) -> bool {
+        panic!("Provenance must not be compared")
+    }
+}
+impl Eq for Provenance {}
+impl std::hash::Hash for Provenance {
+    fn hash<H: std::hash::Hasher>(&self, _state: &mut H) {
+        panic!("Provenance must not be hashed")
+    }
+}
+
 /// The "extra" information a pointer has over a regular AllocId.
 #[derive(Copy, Clone, PartialEq)]
 pub enum ProvenanceExtra {