5
5
pub mod exports;
6
6
pub mod map;
7
7
8
+ use crate :: ich:: StableHashingContext ;
8
9
use crate :: ty:: query:: Providers ;
9
10
use crate :: ty:: TyCtxt ;
10
11
use rustc_data_structures:: cold_path;
11
12
use rustc_data_structures:: fx:: FxHashMap ;
13
+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
12
14
use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
13
15
use rustc_hir:: print;
14
16
use rustc_hir:: Body ;
@@ -25,19 +27,39 @@ pub struct HirOwner<'tcx> {
25
27
node : Node < ' tcx > ,
26
28
}
27
29
28
- #[ derive( HashStable , Clone ) ]
30
+ #[ derive( Clone ) ]
29
31
pub struct HirItem < ' tcx > {
30
32
parent : ItemLocalId ,
31
33
node : Node < ' tcx > ,
32
34
}
33
35
34
- #[ derive( HashStable ) ]
36
+ impl < ' a , ' tcx > HashStable < StableHashingContext < ' a > > for HirItem < ' tcx > {
37
+ fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
38
+ let HirItem { parent, node } = self ;
39
+ hcx. while_hashing_hir_bodies ( false , |hcx| {
40
+ parent. hash_stable ( hcx, hasher) ;
41
+ node. hash_stable ( hcx, hasher) ;
42
+ } ) ;
43
+ }
44
+ }
45
+
35
46
pub struct HirOwnerItems < ' tcx > {
36
- // owner: &'tcx HirOwner <'tcx>,
47
+ owner : Node < ' tcx > ,
37
48
items : IndexVec < ItemLocalId , Option < HirItem < ' tcx > > > ,
38
49
bodies : FxHashMap < ItemLocalId , & ' tcx Body < ' tcx > > ,
39
50
}
40
51
52
+ impl < ' a , ' tcx > HashStable < StableHashingContext < ' a > > for HirOwnerItems < ' tcx > {
53
+ fn hash_stable ( & self , hcx : & mut StableHashingContext < ' a > , hasher : & mut StableHasher ) {
54
+ // We ignore the `items` and `bodies` fields since these refer to information reachable
55
+ // when hashing `owner` with its bodies.
56
+ let HirOwnerItems { owner, items : _, bodies : _ } = * self ;
57
+ hcx. while_hashing_hir_bodies ( true , |hcx| {
58
+ owner. hash_stable ( hcx, hasher) ;
59
+ } ) ;
60
+ }
61
+ }
62
+
41
63
/// A wrapper type which allows you to access HIR.
42
64
#[ derive( Clone ) ]
43
65
pub struct Hir < ' tcx > {
0 commit comments