@@ -13,7 +13,6 @@ use rustc_hir::itemlikevisit::ItemLikeVisitor;
1313use rustc_hir:: * ;
1414use rustc_index:: vec:: Idx ;
1515use rustc_middle:: hir:: nested_filter;
16- use rustc_span:: def_id:: StableCrateId ;
1716use rustc_span:: hygiene:: MacroKind ;
1817use rustc_span:: source_map:: Spanned ;
1918use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -1091,56 +1090,21 @@ impl<'hir> intravisit::Map<'hir> for Map<'hir> {
10911090
10921091pub ( super ) fn crate_hash ( tcx : TyCtxt < ' _ > , crate_num : CrateNum ) -> Svh {
10931092 debug_assert_eq ! ( crate_num, LOCAL_CRATE ) ;
1094- let krate = tcx. hir_crate ( ( ) ) ;
1095- let hir_body_hash = krate. hir_hash ;
1096-
1097- let upstream_crates = upstream_crates ( tcx) ;
1098-
10991093 // We hash the final, remapped names of all local source files so we
11001094 // don't have to include the path prefix remapping commandline args.
11011095 // If we included the full mapping in the SVH, we could only have
11021096 // reproducible builds by compiling from the same directory. So we just
11031097 // hash the result of the mapping instead of the mapping itself.
1104- let mut source_file_names : Vec < _ > = tcx
1098+ let mut source_file_hashes : Vec < _ > = tcx
11051099 . sess
11061100 . source_map ( )
11071101 . files ( )
11081102 . iter ( )
11091103 . filter ( |source_file| source_file. cnum == LOCAL_CRATE )
1110- . map ( |source_file| source_file. name_hash )
1104+ . map ( |source_file| ( source_file. name_hash , source_file . src_hash ) )
11111105 . collect ( ) ;
1106+ source_file_hashes. sort_unstable_by_key ( |& ( name_hash, _) | name_hash) ;
11121107
1113- source_file_names. sort_unstable ( ) ;
1114-
1115- let mut hcx = tcx. create_stable_hashing_context ( ) ;
1116- let mut stable_hasher = StableHasher :: new ( ) ;
1117- hir_body_hash. hash_stable ( & mut hcx, & mut stable_hasher) ;
1118- upstream_crates. hash_stable ( & mut hcx, & mut stable_hasher) ;
1119- source_file_names. hash_stable ( & mut hcx, & mut stable_hasher) ;
1120- if tcx. sess . opts . debugging_opts . incremental_relative_spans {
1121- let definitions = & tcx. untracked_resolutions . definitions ;
1122- let mut owner_spans: Vec < _ > = krate
1123- . owners
1124- . iter_enumerated ( )
1125- . filter_map ( |( def_id, info) | {
1126- let _ = info. as_owner ( ) ?;
1127- let def_path_hash = definitions. def_path_hash ( def_id) ;
1128- let span = definitions. def_span ( def_id) ;
1129- debug_assert_eq ! ( span. parent( ) , None ) ;
1130- Some ( ( def_path_hash, span) )
1131- } )
1132- . collect ( ) ;
1133- owner_spans. sort_unstable_by_key ( |bn| bn. 0 ) ;
1134- owner_spans. hash_stable ( & mut hcx, & mut stable_hasher) ;
1135- }
1136- tcx. sess . opts . dep_tracking_hash ( true ) . hash_stable ( & mut hcx, & mut stable_hasher) ;
1137- tcx. sess . local_stable_crate_id ( ) . hash_stable ( & mut hcx, & mut stable_hasher) ;
1138-
1139- let crate_hash: Fingerprint = stable_hasher. finish ( ) ;
1140- Svh :: new ( crate_hash. to_smaller_hash ( ) )
1141- }
1142-
1143- fn upstream_crates ( tcx : TyCtxt < ' _ > ) -> Vec < ( StableCrateId , Svh ) > {
11441108 let mut upstream_crates: Vec < _ > = tcx
11451109 . crates ( ( ) )
11461110 . iter ( )
@@ -1151,7 +1115,20 @@ fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
11511115 } )
11521116 . collect ( ) ;
11531117 upstream_crates. sort_unstable_by_key ( |& ( stable_crate_id, _) | stable_crate_id) ;
1154- upstream_crates
1118+
1119+ let mut cfg_opts: Vec < _ > = tcx. sess . parse_sess . config . iter ( ) . collect ( ) ;
1120+ cfg_opts. sort_unstable_by_key ( |& ( symbol, _) | symbol. as_str ( ) ) ;
1121+
1122+ let mut hcx = tcx. create_stable_hashing_context ( ) ;
1123+ let mut stable_hasher = StableHasher :: new ( ) ;
1124+ source_file_hashes. hash_stable ( & mut hcx, & mut stable_hasher) ;
1125+ cfg_opts. hash_stable ( & mut hcx, & mut stable_hasher) ;
1126+ upstream_crates. hash_stable ( & mut hcx, & mut stable_hasher) ;
1127+ tcx. sess . opts . dep_tracking_hash ( true ) . hash_stable ( & mut hcx, & mut stable_hasher) ;
1128+ tcx. sess . local_stable_crate_id ( ) . hash_stable ( & mut hcx, & mut stable_hasher) ;
1129+
1130+ let crate_hash: Fingerprint = stable_hasher. finish ( ) ;
1131+ Svh :: new ( crate_hash. to_smaller_hash ( ) )
11551132}
11561133
11571134fn hir_id_to_string ( map : Map < ' _ > , id : HirId ) -> String {
0 commit comments