@@ -187,7 +187,11 @@ impl fmt::Display for MiriMemoryKind {
187
187
pub type MemoryKind = interpret:: MemoryKind < MiriMemoryKind > ;
188
188
189
189
/// 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 ) ]
191
195
pub enum Provenance {
192
196
/// For pointers with concrete provenance. we exactly know which allocation they are attached to
193
197
/// and what their borrow tag is.
@@ -215,24 +219,6 @@ pub enum Provenance {
215
219
Wildcard ,
216
220
}
217
221
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
-
236
222
/// The "extra" information a pointer has over a regular AllocId.
237
223
#[ derive( Copy , Clone , PartialEq ) ]
238
224
pub enum ProvenanceExtra {
@@ -460,7 +446,7 @@ pub struct MiriMachine<'tcx> {
460
446
pub ( crate ) isolated_op : IsolatedOp ,
461
447
462
448
/// Whether to enforce the validity invariant.
463
- pub ( crate ) validate : bool ,
449
+ pub ( crate ) validation : ValidationMode ,
464
450
465
451
/// The table of file descriptors.
466
452
pub ( crate ) fds : shims:: FdTable ,
@@ -659,7 +645,7 @@ impl<'tcx> MiriMachine<'tcx> {
659
645
cmd_line : None ,
660
646
tls : TlsData :: default ( ) ,
661
647
isolated_op : config. isolated_op ,
662
- validate : config. validate ,
648
+ validation : config. validation ,
663
649
fds : shims:: FdTable :: init ( config. mute_stdout_stderr ) ,
664
650
dirs : Default :: default ( ) ,
665
651
layouts,
@@ -801,7 +787,7 @@ impl VisitProvenance for MiriMachine<'_> {
801
787
fds,
802
788
tcx : _,
803
789
isolated_op : _,
804
- validate : _,
790
+ validation : _,
805
791
clock : _,
806
792
layouts : _,
807
793
static_roots : _,
@@ -943,7 +929,14 @@ impl<'tcx> Machine<'tcx> for MiriMachine<'tcx> {
943
929
944
930
#[ inline( always) ]
945
931
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
947
940
}
948
941
949
942
#[ inline( always) ]
0 commit comments