15
15
16
16
use self :: SawExprComponent :: * ;
17
17
use self :: SawAbiComponent :: * ;
18
- use syntax:: ast:: { self , Name , NodeId , Attribute } ;
18
+ use syntax:: ast:: { self , Name , NodeId } ;
19
19
use syntax:: parse:: token;
20
20
use syntax_pos:: { Span , NO_EXPANSION , COMMAND_LINE_EXPN , BytePos } ;
21
21
use rustc:: hir;
@@ -24,6 +24,7 @@ use rustc::hir::def::{Def, PathResolution};
24
24
use rustc:: hir:: def_id:: DefId ;
25
25
use rustc:: hir:: intravisit as visit;
26
26
use rustc:: ty:: TyCtxt ;
27
+ use rustc_data_structures:: fnv;
27
28
use std:: hash:: { Hash , SipHasher } ;
28
29
29
30
use super :: def_path_hash:: DefPathHashes ;
@@ -526,7 +527,7 @@ impl<'a, 'hash, 'tcx> visit::Visitor<'tcx> for StrictVersionHashVisitor<'a, 'has
526
527
visit:: walk_assoc_type_binding ( self , type_binding)
527
528
}
528
529
529
- fn visit_attribute ( & mut self , _: & Attribute ) {
530
+ fn visit_attribute ( & mut self , _: & ast :: Attribute ) {
530
531
// We explicitly do not use this method, since doing that would
531
532
// implicitly impose an order on the attributes being hashed, while we
532
533
// explicitly don't want their order to matter
@@ -658,28 +659,34 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
658
659
s. hash ( self . st ) ;
659
660
// Sort subitems so the hash does not depend on their order
660
661
let indices = self . indices_sorted_by ( & items, |p| {
661
- meta_item_sort_key ( & * p )
662
+ ( p . name ( ) , fnv :: hash ( & p . literal ( ) . map ( |i| & i . node ) ) )
662
663
} ) ;
663
664
items. len ( ) . hash ( self . st ) ;
664
665
for ( index, & item_index) in indices. iter ( ) . enumerate ( ) {
665
666
index. hash ( self . st ) ;
666
- self . hash_meta_item ( & items[ item_index] ) ;
667
+ let nested_meta_item: & ast:: NestedMetaItemKind = & items[ item_index] . node ;
668
+ self . hash_discriminant ( nested_meta_item) ;
669
+ match * nested_meta_item {
670
+ ast:: NestedMetaItemKind :: MetaItem ( ref meta_item) => {
671
+ self . hash_meta_item ( meta_item) ;
672
+ }
673
+ ast:: NestedMetaItemKind :: Literal ( ref lit) => {
674
+ lit. node . hash ( self . st ) ;
675
+ }
676
+ }
667
677
}
668
678
}
669
679
}
670
680
}
671
681
672
- pub fn hash_attributes ( & mut self , attributes : & [ Attribute ] ) {
682
+ pub fn hash_attributes ( & mut self , attributes : & [ ast :: Attribute ] ) {
673
683
debug ! ( "hash_attributes: st={:?}" , self . st) ;
674
- let indices = self . indices_sorted_by ( attributes, |attr| {
675
- meta_item_sort_key ( & attr. node . value )
676
- } ) ;
684
+ let indices = self . indices_sorted_by ( attributes, |attr| attr. name ( ) ) ;
677
685
678
686
for i in indices {
679
687
let attr = & attributes[ i] . node ;
680
-
681
688
if !attr. is_sugared_doc &&
682
- !IGNORED_ATTRIBUTES . contains ( & & * meta_item_sort_key ( & attr. value ) ) {
689
+ !IGNORED_ATTRIBUTES . contains ( & & * attr. value . name ( ) ) {
683
690
SawAttribute ( attr. style ) . hash ( self . st ) ;
684
691
self . hash_meta_item ( & * attr. value ) ;
685
692
}
@@ -696,11 +703,3 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
696
703
indices
697
704
}
698
705
}
699
-
700
- fn meta_item_sort_key ( item : & ast:: MetaItem ) -> token:: InternedString {
701
- match item. node {
702
- ast:: MetaItemKind :: Word ( ref s) |
703
- ast:: MetaItemKind :: NameValue ( ref s, _) |
704
- ast:: MetaItemKind :: List ( ref s, _) => s. clone ( )
705
- }
706
- }
0 commit comments