@@ -7,9 +7,10 @@ use rustc_data_structures::sorted_map::SortedMap;
77use rustc_target:: abi:: { HasDataLayout , Size } ;
88
99use super :: { alloc_range, AllocError , AllocId , AllocRange , AllocResult , Provenance } ;
10+ use rustc_serialize:: { Decodable , Decoder , Encodable , Encoder } ;
1011
1112/// Stores the provenance information of pointers stored in memory.
12- #[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug , TyEncodable , TyDecodable ) ]
13+ #[ derive( Clone , PartialEq , Eq , PartialOrd , Ord , Hash , Debug ) ]
1314#[ derive( HashStable ) ]
1415pub struct ProvenanceMap < Prov = AllocId > {
1516 /// Provenance in this map applies from the given offset for an entire pointer-size worth of
@@ -21,6 +22,20 @@ pub struct ProvenanceMap<Prov = AllocId> {
2122 bytes : Option < Box < SortedMap < Size , Prov > > > ,
2223}
2324
25+ impl < D : Decoder , Prov : Decodable < D > > Decodable < D > for ProvenanceMap < Prov > {
26+ fn decode ( d : & mut D ) -> Self {
27+ Self { ptrs : Decodable :: decode ( d) , bytes : None }
28+ }
29+ }
30+
31+ impl < S : Encoder , Prov : Encodable < S > > Encodable < S > for ProvenanceMap < Prov > {
32+ fn encode ( & self , s : & mut S ) {
33+ let Self { ptrs, bytes } = self ;
34+ debug_assert ! ( bytes. is_none( ) ) ;
35+ ptrs. encode ( s)
36+ }
37+ }
38+
2439impl < Prov > ProvenanceMap < Prov > {
2540 pub fn new ( ) -> Self {
2641 ProvenanceMap { ptrs : SortedMap :: new ( ) , bytes : None }
0 commit comments