@@ -3,6 +3,7 @@ use std::fmt::Write;
33use std:: mem;
44
55use syntax:: source_map:: { self , Span , DUMMY_SP } ;
6+ use rustc:: ich:: StableHashingContext ;
67use rustc:: hir:: def_id:: DefId ;
78use rustc:: hir:: def:: DefKind ;
89use rustc:: mir;
@@ -18,6 +19,8 @@ use rustc::mir::interpret::{
1819 InterpResult , truncate, sign_extend,
1920} ;
2021use rustc_data_structures:: fx:: FxHashMap ;
22+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
23+ use rustc_macros:: HashStable ;
2124
2225use super :: {
2326 Immediate , Operand , MemPlace , MPlaceTy , Place , PlaceTy , ScalarMaybeUndef ,
@@ -93,7 +96,7 @@ pub struct Frame<'mir, 'tcx, Tag=(), Extra=()> {
9396 pub stmt : usize ,
9497}
9598
96- #[ derive( Clone , Eq , PartialEq , Debug ) ] // Miri debug-prints these
99+ #[ derive( Clone , Eq , PartialEq , Debug , HashStable ) ] // Miri debug-prints these
97100pub enum StackPopCleanup {
98101 /// Jump to the next block in the caller, or cause UB if None (that's a function
99102 /// that may never return). Also store layout of return place so
@@ -109,15 +112,16 @@ pub enum StackPopCleanup {
109112}
110113
111114/// State of a local variable including a memoized layout
112- #[ derive( Clone , PartialEq , Eq ) ]
115+ #[ derive( Clone , PartialEq , Eq , HashStable ) ]
113116pub struct LocalState < ' tcx , Tag =( ) , Id =AllocId > {
114117 pub value : LocalValue < Tag , Id > ,
115118 /// Don't modify if `Some`, this is only used to prevent computing the layout twice
119+ #[ stable_hasher( ignore) ]
116120 pub layout : Cell < Option < TyLayout < ' tcx > > > ,
117121}
118122
119123/// 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
121125pub enum LocalValue < Tag =( ) , Id =AllocId > {
122126 /// This local is not currently alive, and cannot be used at all.
123127 Dead ,
@@ -827,3 +831,21 @@ impl<'mir, 'tcx, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
827831 frames
828832 }
829833}
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