@@ -6,11 +6,10 @@ use rustc_data_structures::svh::Svh;
66use rustc_data_structures:: sync:: { DynSend , DynSync , par_for_each_in, try_par_for_each_in} ;
77use rustc_hir:: def:: { DefKind , Res } ;
88use 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 } ;
1010use rustc_hir:: intravisit:: Visitor ;
1111use rustc_hir:: * ;
1212use rustc_hir_pretty as pprust_hir;
13- use rustc_index:: IndexSlice ;
1413use rustc_span:: def_id:: StableCrateId ;
1514use rustc_span:: { ErrorGuaranteed , Ident , Span , Symbol , kw, sym, with_metavar_spans} ;
1615
@@ -1130,13 +1129,13 @@ impl<'tcx> pprust_hir::PpAnn for TyCtxt<'tcx> {
11301129
11311130/// Compute the hash for the HIR of the full crate.
11321131/// 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) ;
11401139 let info = info. as_owner ( ) ?;
11411140 let def_path_hash = tcx. hir_def_path_hash ( def_id) ;
11421141 Some ( ( def_path_hash, info) )
@@ -1152,8 +1151,8 @@ fn compute_hir_hash(
11521151}
11531152
11541153pub ( 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 ) ;
11571156
11581157 let upstream_crates = upstream_crates ( tcx) ;
11591158
@@ -1196,7 +1195,6 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, _: LocalCrate) -> Svh {
11961195 source_file_names. hash_stable ( & mut hcx, & mut stable_hasher) ;
11971196 debugger_visualizers. hash_stable ( & mut hcx, & mut stable_hasher) ;
11981197 if tcx. sess . opts . incremental . is_some ( ) {
1199- let definitions = tcx. untracked ( ) . definitions . freeze ( ) ;
12001198 let mut owner_spans: Vec < _ > = definitions
12011199 . def_path_table ( )
12021200 . def_keys ( )
0 commit comments