@@ -1066,18 +1066,8 @@ impl<'hir> intravisit::Map<'hir> for Map<'hir> {
10661066
10671067pub ( super ) fn crate_hash ( tcx : TyCtxt < ' _ > , crate_num : CrateNum ) -> Svh {
10681068 debug_assert_eq ! ( crate_num, LOCAL_CRATE ) ;
1069- let mut hir_body_nodes: Vec < _ > = tcx
1070- . untracked_resolutions
1071- . definitions
1072- . def_path_table ( )
1073- . all_def_path_hashes_and_def_ids ( )
1074- . filter_map ( |( def_path_hash, local_def_index) | {
1075- let def_id = LocalDefId { local_def_index } ;
1076- let hash = tcx. hir_crate ( ( ) ) . owners [ def_id] . as_ref ( ) ?. nodes . hash ;
1077- Some ( ( def_path_hash, hash, def_id) )
1078- } )
1079- . collect ( ) ;
1080- hir_body_nodes. sort_unstable_by_key ( |bn| bn. 0 ) ;
1069+ let krate = tcx. hir_crate ( ( ) ) ;
1070+ let hir_body_hash = krate. hir_hash ;
10811071
10821072 let upstream_crates = upstream_crates ( tcx) ;
10831073
@@ -1099,22 +1089,25 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
10991089
11001090 let mut hcx = tcx. create_stable_hashing_context ( ) ;
11011091 let mut stable_hasher = StableHasher :: new ( ) ;
1102- for ( def_path_hash, fingerprint, def_id) in hir_body_nodes. iter ( ) {
1103- def_path_hash. 0 . hash_stable ( & mut hcx, & mut stable_hasher) ;
1104- fingerprint. hash_stable ( & mut hcx, & mut stable_hasher) ;
1105- tcx. untracked_crate . owners [ * def_id]
1106- . as_ref ( )
1107- . unwrap ( )
1108- . attrs
1109- . hash_stable ( & mut hcx, & mut stable_hasher) ;
1110- if tcx. sess . opts . debugging_opts . incremental_relative_spans {
1111- let span = tcx. untracked_resolutions . definitions . def_span ( * def_id) ;
1112- debug_assert_eq ! ( span. parent( ) , None ) ;
1113- span. hash_stable ( & mut hcx, & mut stable_hasher) ;
1114- }
1115- }
1092+ hir_body_hash. hash_stable ( & mut hcx, & mut stable_hasher) ;
11161093 upstream_crates. hash_stable ( & mut hcx, & mut stable_hasher) ;
11171094 source_file_names. hash_stable ( & mut hcx, & mut stable_hasher) ;
1095+ if tcx. sess . opts . debugging_opts . incremental_relative_spans {
1096+ let definitions = & tcx. untracked_resolutions . definitions ;
1097+ let mut owner_spans: Vec < _ > = krate
1098+ . owners
1099+ . iter_enumerated ( )
1100+ . filter_map ( |( def_id, info) | {
1101+ let _ = info. as_ref ( ) ?;
1102+ let def_path_hash = definitions. def_path_hash ( def_id) ;
1103+ let span = definitions. def_span ( def_id) ;
1104+ debug_assert_eq ! ( span. parent( ) , None ) ;
1105+ Some ( ( def_path_hash, span) )
1106+ } )
1107+ . collect ( ) ;
1108+ owner_spans. sort_unstable_by_key ( |bn| bn. 0 ) ;
1109+ owner_spans. hash_stable ( & mut hcx, & mut stable_hasher) ;
1110+ }
11181111 tcx. sess . opts . dep_tracking_hash ( true ) . hash_stable ( & mut hcx, & mut stable_hasher) ;
11191112 tcx. sess . local_stable_crate_id ( ) . hash_stable ( & mut hcx, & mut stable_hasher) ;
11201113
0 commit comments