55pub mod exports;
66pub mod map;
77
8+ use crate :: ich:: StableHashingContext ;
89use crate :: ty:: query:: Providers ;
910use crate :: ty:: TyCtxt ;
1011use rustc_data_structures:: cold_path;
1112use rustc_data_structures:: fx:: FxHashMap ;
13+ use rustc_data_structures:: stable_hasher:: { HashStable , StableHasher } ;
1214use rustc_hir:: def_id:: { DefId , LOCAL_CRATE } ;
1315use rustc_hir:: print;
1416use rustc_hir:: Body ;
@@ -25,19 +27,39 @@ pub struct HirOwner<'tcx> {
2527 node : Node < ' tcx > ,
2628}
2729
28- #[ derive( HashStable , Clone ) ]
30+ #[ derive( Clone ) ]
2931pub struct HirItem < ' tcx > {
3032 parent : ItemLocalId ,
3133 node : Node < ' tcx > ,
3234}
3335
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+
3546pub struct HirOwnerItems < ' tcx > {
36- // owner: &'tcx HirOwner <'tcx>,
47+ owner : Node < ' tcx > ,
3748 items : IndexVec < ItemLocalId , Option < HirItem < ' tcx > > > ,
3849 bodies : FxHashMap < ItemLocalId , & ' tcx Body < ' tcx > > ,
3950}
4051
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+
4163/// A wrapper type which allows you to access HIR.
4264#[ derive( Clone ) ]
4365pub struct Hir < ' tcx > {
0 commit comments