@@ -187,7 +187,11 @@ impl fmt::Display for MiriMemoryKind {
187187pub type MemoryKind = interpret:: MemoryKind < MiriMemoryKind > ;
188188
189189/// Pointer provenance.
190- #[ derive( Clone , Copy ) ]
190+ // This needs to be `Eq`+`Hash` because the `Machine` trait needs that because validity checking
191+ // *might* be recursive and then it has to track which places have already been visited.
192+ // These implementations are a bit questionable, and it means we may check the same place multiple
193+ // times with different provenance, but that is in general not wrong.
194+ #[ derive( Clone , Copy , PartialEq , Eq , Hash ) ]
191195pub enum Provenance {
192196 /// For pointers with concrete provenance. we exactly know which allocation they are attached to
193197 /// and what their borrow tag is.
@@ -215,24 +219,6 @@ pub enum Provenance {
215219 Wildcard ,
216220}
217221
218- // This needs to be `Eq`+`Hash` because the `Machine` trait needs that because validity checking
219- // *might* be recursive and then it has to track which places have already been visited.
220- // However, comparing provenance is meaningless, since `Wildcard` might be any provenance -- and of
221- // course we don't actually do recursive checking.
222- // We could change `RefTracking` to strip provenance for its `seen` set but that type is generic so that is quite annoying.
223- // Instead owe add the required instances but make them panic.
224- impl PartialEq for Provenance {
225- fn eq ( & self , _other : & Self ) -> bool {
226- panic ! ( "Provenance must not be compared" )
227- }
228- }
229- impl Eq for Provenance { }
230- impl std:: hash:: Hash for Provenance {
231- fn hash < H : std:: hash:: Hasher > ( & self , _state : & mut H ) {
232- panic ! ( "Provenance must not be hashed" )
233- }
234- }
235-
236222/// The "extra" information a pointer has over a regular AllocId.
237223#[ derive( Copy , Clone , PartialEq ) ]
238224pub enum ProvenanceExtra {
@@ -460,7 +446,7 @@ pub struct MiriMachine<'tcx> {
460446 pub ( crate ) isolated_op : IsolatedOp ,
461447
462448 /// Whether to enforce the validity invariant.
463- pub ( crate ) validate : bool ,
449+ pub ( crate ) validation : ValidationMode ,
464450
465451 /// The table of file descriptors.
466452 pub ( crate ) fds : shims:: FdTable ,
@@ -659,7 +645,7 @@ impl<'tcx> MiriMachine<'tcx> {
659645 cmd_line : None ,
660646 tls : TlsData :: default ( ) ,
661647 isolated_op : config. isolated_op ,
662- validate : config. validate ,
648+ validation : config. validation ,
663649 fds : shims:: FdTable :: init ( config. mute_stdout_stderr ) ,
664650 dirs : Default :: default ( ) ,
665651 layouts,
@@ -801,7 +787,7 @@ impl VisitProvenance for MiriMachine<'_> {
801787 fds,
802788 tcx : _,
803789 isolated_op : _,
804- validate : _,
790+ validation : _,
805791 clock : _,
806792 layouts : _,
807793 static_roots : _,
@@ -943,7 +929,14 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
943929
944930 #[ inline( always) ]
945931 fn enforce_validity ( ecx : & MiriInterpCx < ' tcx > , _layout : TyAndLayout < ' tcx > ) -> bool {
946- ecx. machine . validate
932+ ecx. machine . validation != ValidationMode :: No
933+ }
934+ #[ inline( always) ]
935+ fn enforce_validity_recursively (
936+ ecx : & InterpCx < ' tcx , Self > ,
937+ _layout : TyAndLayout < ' tcx > ,
938+ ) -> bool {
939+ ecx. machine . validation == ValidationMode :: Deep
947940 }
948941
949942 #[ inline( always) ]
0 commit comments