@@ -6,11 +6,10 @@ use rustc_data_structures::svh::Svh;
6
6
use rustc_data_structures:: sync:: { DynSend , DynSync , par_for_each_in, try_par_for_each_in} ;
7
7
use rustc_hir:: def:: { DefKind , Res } ;
8
8
use rustc_hir:: def_id:: { CRATE_DEF_ID , DefId , LOCAL_CRATE , LocalDefId , LocalModDefId } ;
9
- use rustc_hir:: definitions:: { DefKey , DefPath , DefPathHash } ;
9
+ use rustc_hir:: definitions:: { DefKey , DefPath , DefPathHash , Definitions } ;
10
10
use rustc_hir:: intravisit:: Visitor ;
11
11
use rustc_hir:: * ;
12
12
use rustc_hir_pretty as pprust_hir;
13
- use rustc_index:: IndexSlice ;
14
13
use rustc_span:: def_id:: StableCrateId ;
15
14
use rustc_span:: { ErrorGuaranteed , Ident , Span , Symbol , kw, sym, with_metavar_spans} ;
16
15
@@ -1130,13 +1129,13 @@ impl<'tcx> pprust_hir::PpAnn for TyCtxt<'tcx> {
1130
1129
1131
1130
/// Compute the hash for the HIR of the full crate.
1132
1131
/// This hash will then be part of the crate_hash which is stored in the metadata.
1133
- fn compute_hir_hash (
1134
- tcx : TyCtxt < ' _ > ,
1135
- owners : & IndexSlice < LocalDefId , MaybeOwner < ' _ > > ,
1136
- ) -> Fingerprint {
1137
- let mut hir_body_nodes : Vec < _ > = owners
1138
- . iter_enumerated ( )
1139
- . filter_map ( | ( def_id, info ) | {
1132
+ fn compute_hir_hash ( tcx : TyCtxt < ' _ > , definitions : & Definitions ) -> Fingerprint {
1133
+ let mut hir_body_nodes : Vec < _ > = definitions
1134
+ . def_path_table ( )
1135
+ . def_keys ( )
1136
+ . filter_map ( |local_def_index| {
1137
+ let def_id = LocalDefId { local_def_index } ;
1138
+ let info = tcx . hir_owner ( def_id) ;
1140
1139
let info = info. as_owner ( ) ?;
1141
1140
let def_path_hash = tcx. hir_def_path_hash ( def_id) ;
1142
1141
Some ( ( def_path_hash, info) )
@@ -1152,8 +1151,8 @@ fn compute_hir_hash(
1152
1151
}
1153
1152
1154
1153
pub ( super ) fn crate_hash ( tcx : TyCtxt < ' _ > , _: LocalCrate ) -> Svh {
1155
- let krate = tcx. hir_crate ( ( ) ) ;
1156
- let hir_body_hash = compute_hir_hash ( tcx, & krate . owners ) ;
1154
+ let definitions = tcx. untracked ( ) . definitions . freeze ( ) ;
1155
+ let hir_body_hash = compute_hir_hash ( tcx, definitions ) ;
1157
1156
1158
1157
let upstream_crates = upstream_crates ( tcx) ;
1159
1158
@@ -1196,7 +1195,6 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh {
1196
1195
source_file_names. hash_stable ( & mut hcx, & mut stable_hasher) ;
1197
1196
debugger_visualizers. hash_stable ( & mut hcx, & mut stable_hasher) ;
1198
1197
if tcx. sess . opts . incremental . is_some ( ) {
1199
- let definitions = tcx. untracked ( ) . definitions . freeze ( ) ;
1200
1198
let mut owner_spans: Vec < _ > = definitions
1201
1199
. def_path_table ( )
1202
1200
. def_keys ( )
0 commit comments