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