@@ -18,16 +18,15 @@ use syntax::abi::Abi;
18
18
use syntax:: ast:: { self , Name , NodeId } ;
19
19
use syntax:: attr;
20
20
use syntax:: parse:: token;
21
- use syntax:: symbol:: { Symbol , InternedString } ;
21
+ use syntax:: symbol:: InternedString ;
22
22
use syntax_pos:: { Span , NO_EXPANSION , COMMAND_LINE_EXPN , BytePos } ;
23
23
use syntax:: tokenstream;
24
24
use rustc:: hir;
25
25
use rustc:: hir:: * ;
26
26
use rustc:: hir:: def:: Def ;
27
27
use rustc:: hir:: def_id:: DefId ;
28
- use rustc:: hir:: intravisit as visit;
28
+ use rustc:: hir:: intravisit:: { self as visit, Visitor } ;
29
29
use rustc:: ty:: TyCtxt ;
30
- use rustc_data_structures:: fnv;
31
30
use std:: hash:: { Hash , Hasher } ;
32
31
33
32
use super :: def_path_hash:: DefPathHashes ;
@@ -559,7 +558,7 @@ macro_rules! hash_span {
559
558
} ) ;
560
559
}
561
560
562
- impl < ' a , ' hash , ' tcx > visit :: Visitor < ' tcx > for StrictVersionHashVisitor < ' a , ' hash , ' tcx > {
561
+ impl < ' a , ' hash , ' tcx > Visitor < ' tcx > for StrictVersionHashVisitor < ' a , ' hash , ' tcx > {
563
562
fn nested_visit_map < ' this > ( & ' this mut self ) -> visit:: NestedVisitorMap < ' this , ' tcx > {
564
563
if self . hash_bodies {
565
564
visit:: NestedVisitorMap :: OnlyBodies ( & self . tcx . hir )
@@ -960,50 +959,24 @@ impl<'a, 'hash, 'tcx> StrictVersionHashVisitor<'a, 'hash, 'tcx> {
960
959
}
961
960
}
962
961
963
- fn hash_meta_item ( & mut self , meta_item : & ast:: MetaItem ) {
964
- debug ! ( "hash_meta_item: st={:?}" , self . st) ;
965
-
966
- // ignoring span information, it doesn't matter here
967
- self . hash_discriminant ( & meta_item. node ) ;
968
- meta_item. name . as_str ( ) . len ( ) . hash ( self . st ) ;
969
- meta_item. name . as_str ( ) . hash ( self . st ) ;
970
-
971
- match meta_item. node {
972
- ast:: MetaItemKind :: Word => { }
973
- ast:: MetaItemKind :: NameValue ( ref lit) => saw_lit ( lit) . hash ( self . st ) ,
974
- ast:: MetaItemKind :: List ( ref items) => {
975
- // Sort subitems so the hash does not depend on their order
976
- let indices = self . indices_sorted_by ( & items, |p| {
977
- ( p. name ( ) . map ( Symbol :: as_str) , fnv:: hash ( & p. literal ( ) . map ( saw_lit) ) )
978
- } ) ;
979
- items. len ( ) . hash ( self . st ) ;
980
- for ( index, & item_index) in indices. iter ( ) . enumerate ( ) {
981
- index. hash ( self . st ) ;
982
- let nested_meta_item: & ast:: NestedMetaItemKind = & items[ item_index] . node ;
983
- self . hash_discriminant ( nested_meta_item) ;
984
- match * nested_meta_item {
985
- ast:: NestedMetaItemKind :: MetaItem ( ref meta_item) => {
986
- self . hash_meta_item ( meta_item) ;
987
- }
988
- ast:: NestedMetaItemKind :: Literal ( ref lit) => {
989
- saw_lit ( lit) . hash ( self . st ) ;
990
- }
991
- }
992
- }
993
- }
994
- }
995
- }
996
-
997
962
pub fn hash_attributes ( & mut self , attributes : & [ ast:: Attribute ] ) {
998
963
debug ! ( "hash_attributes: st={:?}" , self . st) ;
999
964
let indices = self . indices_sorted_by ( attributes, |attr| attr. name ( ) ) ;
1000
965
1001
966
for i in indices {
1002
967
let attr = & attributes[ i] ;
1003
- if !attr. is_sugared_doc &&
1004
- !IGNORED_ATTRIBUTES . contains ( & & * attr. value . name ( ) . as_str ( ) ) {
968
+ match attr. name ( ) {
969
+ Some ( name) if IGNORED_ATTRIBUTES . contains ( & & * name. as_str ( ) ) => continue ,
970
+ _ => { }
971
+ } ;
972
+ if !attr. is_sugared_doc {
1005
973
SawAttribute ( attr. style ) . hash ( self . st ) ;
1006
- self . hash_meta_item ( & attr. value ) ;
974
+ for segment in & attr. path . segments {
975
+ SawIdent ( segment. identifier . name . as_str ( ) ) . hash ( self . st ) ;
976
+ }
977
+ for tt in attr. tokens . trees ( ) {
978
+ self . hash_token_tree ( & tt) ;
979
+ }
1007
980
}
1008
981
}
1009
982
}
0 commit comments