From b4eff16e0c943ef8250c0d49e1bc5501ee11467b Mon Sep 17 00:00:00 2001 From: Ralf Jung Date: Sat, 27 Aug 2022 15:55:00 -0400 Subject: [PATCH] ensure we don't compare provenance --- src/machine.rs | 20 +++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/src/machine.rs b/src/machine.rs index 6bba5bcc5f0d..0862b3b17c6d 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(&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 {