@@ -3,6 +3,7 @@ use std::fmt::Write;
3
3
use std:: mem;
4
4
5
5
use syntax:: source_map:: { self , Span , DUMMY_SP } ;
6
+ use rustc:: ich:: StableHashingContext ;
6
7
use rustc:: hir:: def_id:: DefId ;
7
8
use rustc:: hir:: def:: DefKind ;
8
9
use rustc:: mir;
@@ -18,6 +19,8 @@ use rustc::mir::interpret::{
18
19
InterpResult , truncate, sign_extend,
19
20
} ;
20
21
use rustc_data_structures:: fx:: FxHashMap ;
22
+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
23
+ use rustc_macros:: HashStable ;
21
24
22
25
use super :: {
23
26
Immediate , Operand , MemPlace , MPlaceTy , Place , PlaceTy , ScalarMaybeUndef ,
@@ -93,7 +96,7 @@ pub struct Frame<'mir, 'tcx, Tag=(), Extra=()> {
93
96
pub stmt : usize ,
94
97
}
95
98
96
- #[ derive( Clone , Eq , PartialEq , Debug ) ] // Miri debug-prints these
99
+ #[ derive( Clone , Eq , PartialEq , Debug , HashStable ) ] // Miri debug-prints these
97
100
pub enum StackPopCleanup {
98
101
/// Jump to the next block in the caller, or cause UB if None (that's a function
99
102
/// that may never return). Also store layout of return place so
@@ -109,15 +112,16 @@ pub enum StackPopCleanup {
109
112
}
110
113
111
114
/// State of a local variable including a memoized layout
112
- #[ derive( Clone , PartialEq , Eq ) ]
115
+ #[ derive( Clone , PartialEq , Eq , HashStable ) ]
113
116
pub struct LocalState < ' tcx , Tag =( ) , Id =AllocId > {
114
117
pub value : LocalValue < Tag , Id > ,
115
118
/// Don't modify if `Some`, this is only used to prevent computing the layout twice
119
+ #[ stable_hasher( ignore) ]
116
120
pub layout : Cell < Option < TyLayout < ' tcx > > > ,
117
121
}
118
122
119
123
/// Current value of a local variable
120
- #[ derive( Clone , PartialEq , Eq , Debug ) ] // Miri debug-prints these
124
+ #[ derive( Clone , PartialEq , Eq , Debug , HashStable ) ] // Miri debug-prints these
121
125
pub enum LocalValue < Tag =( ) , Id =AllocId > {
122
126
/// This local is not currently alive, and cannot be used at all.
123
127
Dead ,
@@ -827,3 +831,21 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
827
831
frames
828
832
}
829
833
}
834
+
835
+ impl < ' ctx , ' mir , ' tcx , Tag , Extra > HashStable < StableHashingContext < ' ctx > >
836
+ for Frame < ' mir , ' tcx , Tag , Extra >
837
+ where Extra : HashStable < StableHashingContext < ' ctx > > ,
838
+ Tag : HashStable < StableHashingContext < ' ctx > >
839
+ {
840
+ fn hash_stable ( & self , hcx : & mut StableHashingContext < ' ctx > , hasher : & mut StableHasher ) {
841
+ self . body . hash_stable ( hcx, hasher) ;
842
+ self . instance . hash_stable ( hcx, hasher) ;
843
+ self . span . hash_stable ( hcx, hasher) ;
844
+ self . return_to_block . hash_stable ( hcx, hasher) ;
845
+ self . return_place . as_ref ( ) . map ( |r| & * * r) . hash_stable ( hcx, hasher) ;
846
+ self . locals . hash_stable ( hcx, hasher) ;
847
+ self . block . hash_stable ( hcx, hasher) ;
848
+ self . stmt . hash_stable ( hcx, hasher) ;
849
+ self . extra . hash_stable ( hcx, hasher) ;
850
+ }
851
+ }
0 commit comments