@@ -87,19 +87,6 @@ impl Svh {
87
87
visit:: walk_crate ( & mut visit, krate) ;
88
88
}
89
89
90
- // FIXME (#14132): This hash is still sensitive to e.g. the
91
- // spans of the crate Attributes and their underlying
92
- // MetaItems; we should make ContentHashable impl for those
93
- // types and then use hash_content. But, since all crate
94
- // attributes should appear near beginning of the file, it is
95
- // not such a big deal to be sensitive to their spans for now.
96
- //
97
- // We hash only the MetaItems instead of the entire Attribute
98
- // to avoid hashing the AttrId
99
- for attr in & krate. attrs {
100
- attr. node . value . hash ( & mut state) ;
101
- }
102
-
103
90
let hash = state. finish ( ) ;
104
91
return Svh {
105
92
hash : ( 0 ..64 ) . step_by ( 4 ) . map ( |i| hex ( hash >> i) ) . collect ( )
@@ -198,6 +185,9 @@ mod svh_visitor {
198
185
SawPat ,
199
186
SawLocal ,
200
187
SawArm ,
188
+ SawAttrWord ,
189
+ SawAttrList ,
190
+ SawAttrNameValue ,
201
191
SawExpr ( SawExprComponent < ' a > ) ,
202
192
SawStmt ( SawStmtComponent ) ,
203
193
}
@@ -487,5 +477,26 @@ mod svh_visitor {
487
477
fn visit_arm ( & mut self , a : & Arm ) {
488
478
SawArm . hash ( self . st ) ; visit:: walk_arm ( self , a)
489
479
}
480
+
481
+ fn visit_attribute ( & mut self , a : & Attribute ) {
482
+ let ref val = a. node . value ;
483
+
484
+ match val. node {
485
+ MetaItem_ :: MetaWord ( ref s) => {
486
+ SawAttrWord . hash ( self . st ) ;
487
+ s. hash ( self . st ) ;
488
+ } ,
489
+ MetaItem_ :: MetaList ( ref s, ref items) => {
490
+ SawAttrList . hash ( self . st ) ;
491
+ s. hash ( self . st ) ;
492
+ items. hash ( self . st ) ;
493
+ } ,
494
+ MetaItem_ :: MetaNameValue ( ref s, ref lit) => {
495
+ SawAttrNameValue . hash ( self . st ) ;
496
+ s. hash ( self . st ) ;
497
+ lit. hash ( self . st ) ;
498
+ } ,
499
+ }
500
+ }
490
501
}
491
502
}
0 commit comments