1515
1616use self :: SawExprComponent :: * ;
1717use self :: SawAbiComponent :: * ;
18- use syntax:: ast:: { self , Name , NodeId , Attribute } ;
18+ use syntax:: ast:: { self , Name , NodeId } ;
1919use syntax:: parse:: token;
2020use syntax_pos:: { Span , NO_EXPANSION , COMMAND_LINE_EXPN , BytePos } ;
2121use rustc:: hir;
@@ -24,6 +24,7 @@ use rustc::hir::def::{Def, PathResolution};
2424use rustc:: hir:: def_id:: DefId ;
2525use rustc:: hir:: intravisit as visit;
2626use rustc:: ty:: TyCtxt ;
27+ use rustc_data_structures:: fnv;
2728use std:: hash:: { Hash , SipHasher } ;
2829
2930use super :: def_path_hash:: DefPathHashes ;
@@ -526,7 +527,7 @@ impl<'a, 'hash, 'tcx> visit::Visitor<'tcx> for StrictVersionHashVisitor<'a, 'has
526527 visit:: walk_assoc_type_binding ( self , type_binding)
527528 }
528529
529- fn visit_attribute ( & mut self , _: & Attribute ) {
530+ fn visit_attribute ( & mut self , _: & ast :: Attribute ) {
530531 // We explicitly do not use this method, since doing that would
531532 // implicitly impose an order on the attributes being hashed, while we
532533 // explicitly don't want their order to matter
@@ -658,28 +659,34 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
658659 s. hash ( self . st ) ;
659660 // Sort subitems so the hash does not depend on their order
660661 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 ) ) )
662663 } ) ;
663664 items. len ( ) . hash ( self . st ) ;
664665 for ( index, & item_index) in indices. iter ( ) . enumerate ( ) {
665666 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+ }
667677 }
668678 }
669679 }
670680 }
671681
672- pub fn hash_attributes ( & mut self , attributes : & [ Attribute ] ) {
682+ pub fn hash_attributes ( & mut self , attributes : & [ ast :: Attribute ] ) {
673683 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 ( ) ) ;
677685
678686 for i in indices {
679687 let attr = & attributes[ i] . node ;
680-
681688 if !attr. is_sugared_doc &&
682- !IGNORED_ATTRIBUTES . contains ( & & * meta_item_sort_key ( & attr. value ) ) {
689+ !IGNORED_ATTRIBUTES . contains ( & & * attr. value . name ( ) ) {
683690 SawAttribute ( attr. style ) . hash ( self . st ) ;
684691 self . hash_meta_item ( & * attr. value ) ;
685692 }
@@ -696,11 +703,3 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
696703 indices
697704 }
698705}
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