28
28
//! at the beginning.
29
29
30
30
use syntax:: ast;
31
- use syntax:: attr:: AttributeMethods ;
32
31
use std:: hash:: { Hash , SipHasher , Hasher } ;
33
32
use rustc:: dep_graph:: DepNode ;
34
33
use rustc:: hir;
35
34
use rustc:: hir:: def_id:: { CRATE_DEF_INDEX , DefId } ;
36
35
use rustc:: hir:: intravisit as visit;
37
36
use rustc:: ty:: TyCtxt ;
38
37
use rustc_data_structures:: fnv:: FnvHashMap ;
38
+ use rustc:: util:: common:: record_time;
39
+ use rustc:: session:: config:: DebugInfoLevel :: NoDebugInfo ;
39
40
40
41
use self :: def_path_hash:: DefPathHashes ;
41
42
use self :: svh_visitor:: StrictVersionHashVisitor ;
@@ -49,19 +50,27 @@ pub fn compute_incremental_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
49
50
-> IncrementalHashesMap {
50
51
let _ignore = tcx. dep_graph . in_ignore ( ) ;
51
52
let krate = tcx. map . krate ( ) ;
52
- let mut visitor = HashItemsVisitor { tcx : tcx,
53
- hashes : FnvHashMap ( ) ,
54
- def_path_hashes : DefPathHashes :: new ( tcx) } ;
55
- visitor. calculate_def_id ( DefId :: local ( CRATE_DEF_INDEX ) , |v| visit:: walk_crate ( v, krate) ) ;
56
- krate. visit_all_items ( & mut visitor) ;
57
- visitor. compute_crate_hash ( ) ;
53
+ let hash_spans = tcx. sess . opts . debuginfo != NoDebugInfo ;
54
+ let mut visitor = HashItemsVisitor {
55
+ tcx : tcx,
56
+ hashes : FnvHashMap ( ) ,
57
+ def_path_hashes : DefPathHashes :: new ( tcx) ,
58
+ hash_spans : hash_spans
59
+ } ;
60
+ record_time ( & tcx. sess . perf_stats . incr_comp_hashes_time , || {
61
+ visitor. calculate_def_id ( DefId :: local ( CRATE_DEF_INDEX ) ,
62
+ |v| visit:: walk_crate ( v, krate) ) ;
63
+ krate. visit_all_items ( & mut visitor) ;
64
+ } ) ;
65
+ record_time ( & tcx. sess . perf_stats . svh_time , || visitor. compute_crate_hash ( ) ) ;
58
66
visitor. hashes
59
67
}
60
68
61
69
struct HashItemsVisitor < ' a , ' tcx : ' a > {
62
70
tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
63
71
def_path_hashes : DefPathHashes < ' a , ' tcx > ,
64
72
hashes : IncrementalHashesMap ,
73
+ hash_spans : bool ,
65
74
}
66
75
67
76
impl < ' a , ' tcx > HashItemsVisitor < ' a , ' tcx > {
@@ -82,7 +91,8 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
82
91
let mut state = SipHasher :: new ( ) ;
83
92
walk_op ( & mut StrictVersionHashVisitor :: new ( & mut state,
84
93
self . tcx ,
85
- & mut self . def_path_hashes ) ) ;
94
+ & mut self . def_path_hashes ,
95
+ self . hash_spans ) ) ;
86
96
let item_hash = state. finish ( ) ;
87
97
self . hashes . insert ( DepNode :: Hir ( def_id) , item_hash) ;
88
98
debug ! ( "calculate_item_hash: def_id={:?} hash={:?}" , def_id, item_hash) ;
@@ -118,9 +128,12 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
118
128
item_hashes. hash ( & mut crate_state) ;
119
129
}
120
130
121
- for attr in & krate. attrs {
122
- debug ! ( "krate attr {:?}" , attr) ;
123
- attr. meta ( ) . hash ( & mut crate_state) ;
131
+ {
132
+ let mut visitor = StrictVersionHashVisitor :: new ( & mut crate_state,
133
+ self . tcx ,
134
+ & mut self . def_path_hashes ,
135
+ self . hash_spans ) ;
136
+ visitor. hash_attributes ( & krate. attrs ) ;
124
137
}
125
138
126
139
let crate_hash = crate_state. finish ( ) ;
0 commit comments