1
1
use crate :: arena:: Arena ;
2
2
use crate :: hir:: map:: { Entry , HirOwnerData , Map } ;
3
- use crate :: hir:: { Owner , OwnerNodes , ParentedNode } ;
3
+ use crate :: hir:: { AttributeMap , Owner , OwnerNodes , ParentedNode } ;
4
4
use crate :: ich:: StableHashingContext ;
5
5
use crate :: middle:: cstore:: CrateStore ;
6
6
use rustc_data_structures:: fingerprint:: Fingerprint ;
@@ -9,7 +9,7 @@ use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
9
9
use rustc_data_structures:: svh:: Svh ;
10
10
use rustc_hir as hir;
11
11
use rustc_hir:: def_id:: CRATE_DEF_INDEX ;
12
- use rustc_hir:: def_id:: { LocalDefId , LOCAL_CRATE } ;
12
+ use rustc_hir:: def_id:: { LocalDefId , CRATE_DEF_ID , LOCAL_CRATE } ;
13
13
use rustc_hir:: definitions:: { self , DefPathHash } ;
14
14
use rustc_hir:: intravisit:: { self , NestedVisitorMap , Visitor } ;
15
15
use rustc_hir:: * ;
@@ -58,18 +58,28 @@ fn insert_vec_map<K: Idx, V: Clone>(map: &mut IndexVec<K, Option<V>>, k: K, v: V
58
58
59
59
fn hash_body (
60
60
hcx : & mut StableHashingContext < ' _ > ,
61
+ def_id : LocalDefId ,
61
62
def_path_hash : DefPathHash ,
62
63
item_like : impl for < ' a > HashStable < StableHashingContext < ' a > > ,
64
+ krate : & Crate < ' _ > ,
63
65
hir_body_nodes : & mut Vec < ( DefPathHash , Fingerprint ) > ,
64
66
) -> Fingerprint {
65
- let hash = {
67
+ // Hash of nodes.
68
+ let hash: Fingerprint = {
66
69
let mut stable_hasher = StableHasher :: new ( ) ;
67
70
hcx. while_hashing_hir_bodies ( true , |hcx| {
68
71
item_like. hash_stable ( hcx, & mut stable_hasher) ;
69
72
} ) ;
70
73
stable_hasher. finish ( )
71
74
} ;
72
- hir_body_nodes. push ( ( def_path_hash, hash) ) ;
75
+ // Hash for crate_hash.
76
+ let hash_with_attrs: Fingerprint = {
77
+ let mut hasher = StableHasher :: new ( ) ;
78
+ hash. hash_stable ( hcx, & mut hasher) ;
79
+ AttributeMap { map : & krate. attrs , prefix : def_id } . hash_stable ( hcx, & mut hasher) ;
80
+ hasher. finish ( )
81
+ } ;
82
+ hir_body_nodes. push ( ( def_path_hash, hash_with_attrs) ) ;
73
83
hash
74
84
}
75
85
@@ -120,7 +130,14 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
120
130
attrs : _,
121
131
} = * krate;
122
132
123
- hash_body ( & mut hcx, root_mod_def_path_hash, item, & mut hir_body_nodes)
133
+ hash_body (
134
+ & mut hcx,
135
+ CRATE_DEF_ID ,
136
+ root_mod_def_path_hash,
137
+ item,
138
+ krate,
139
+ & mut hir_body_nodes,
140
+ )
124
141
} ;
125
142
126
143
let mut collector = NodeCollector {
@@ -186,6 +203,7 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
186
203
let crate_hash_input = (
187
204
( ( node_hashes, upstream_crates) , source_file_names) ,
188
205
( commandline_args_hash, crate_disambiguator. to_fingerprint ( ) ) ,
206
+ & self . krate . non_exported_macro_attrs ,
189
207
) ;
190
208
191
209
let mut stable_hasher = StableHasher :: new ( ) ;
@@ -297,7 +315,14 @@ impl<'a, 'hir> NodeCollector<'a, 'hir> {
297
315
298
316
let def_path_hash = self . definitions . def_path_hash ( dep_node_owner) ;
299
317
300
- let hash = hash_body ( & mut self . hcx , def_path_hash, item_like, & mut self . hir_body_nodes ) ;
318
+ let hash = hash_body (
319
+ & mut self . hcx ,
320
+ dep_node_owner,
321
+ def_path_hash,
322
+ item_like,
323
+ self . krate ,
324
+ & mut self . hir_body_nodes ,
325
+ ) ;
301
326
302
327
self . current_dep_node_owner = dep_node_owner;
303
328
f ( self , hash) ;
0 commit comments