@@ -35,6 +35,8 @@ use rustc::hir::def_id::{CRATE_DEF_INDEX, DefId};
3535use rustc:: hir:: intravisit as visit;
3636use rustc:: ty:: TyCtxt ;
3737use rustc_data_structures:: fnv:: FnvHashMap ;
38+ use rustc:: util:: common:: record_time;
39+ use rustc:: session:: config:: DebugInfoLevel :: NoDebugInfo ;
3840
3941use self :: def_path_hash:: DefPathHashes ;
4042use self :: svh_visitor:: StrictVersionHashVisitor ;
@@ -48,19 +50,27 @@ pub fn compute_incremental_hashes_map<'a, 'tcx: 'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>)
4850 -> IncrementalHashesMap {
4951 let _ignore = tcx. dep_graph . in_ignore ( ) ;
5052 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 ( ) ) ;
5766 visitor. hashes
5867}
5968
6069struct HashItemsVisitor < ' a , ' tcx : ' a > {
6170 tcx : TyCtxt < ' a , ' tcx , ' tcx > ,
6271 def_path_hashes : DefPathHashes < ' a , ' tcx > ,
6372 hashes : IncrementalHashesMap ,
73+ hash_spans : bool ,
6474}
6575
6676impl < ' a , ' tcx > HashItemsVisitor < ' a , ' tcx > {
@@ -81,7 +91,8 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
8191 let mut state = SipHasher :: new ( ) ;
8292 walk_op ( & mut StrictVersionHashVisitor :: new ( & mut state,
8393 self . tcx ,
84- & mut self . def_path_hashes ) ) ;
94+ & mut self . def_path_hashes ,
95+ self . hash_spans ) ) ;
8596 let item_hash = state. finish ( ) ;
8697 self . hashes . insert ( DepNode :: Hir ( def_id) , item_hash) ;
8798 debug ! ( "calculate_item_hash: def_id={:?} hash={:?}" , def_id, item_hash) ;
@@ -117,9 +128,12 @@ impl<'a, 'tcx> HashItemsVisitor<'a, 'tcx> {
117128 item_hashes. hash ( & mut crate_state) ;
118129 }
119130
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 ) ;
123137 }
124138
125139 let crate_hash = crate_state. finish ( ) ;
0 commit comments