@@ -13,7 +13,6 @@ use rustc_hir::itemlikevisit::ItemLikeVisitor;
13
13
use rustc_hir:: * ;
14
14
use rustc_index:: vec:: Idx ;
15
15
use rustc_middle:: hir:: nested_filter;
16
- use rustc_span:: def_id:: StableCrateId ;
17
16
use rustc_span:: hygiene:: MacroKind ;
18
17
use rustc_span:: source_map:: Spanned ;
19
18
use rustc_span:: symbol:: { kw, sym, Ident , Symbol } ;
@@ -1091,56 +1090,21 @@ impl<'hir> intravisit::Map<'hir> for Map<'hir> {
1091
1090
1092
1091
pub ( super ) fn crate_hash ( tcx : TyCtxt < ' _ > , crate_num : CrateNum ) -> Svh {
1093
1092
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
-
1099
1093
// We hash the final, remapped names of all local source files so we
1100
1094
// don't have to include the path prefix remapping commandline args.
1101
1095
// If we included the full mapping in the SVH, we could only have
1102
1096
// reproducible builds by compiling from the same directory. So we just
1103
1097
// 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
1105
1099
. sess
1106
1100
. source_map ( )
1107
1101
. files ( )
1108
1102
. iter ( )
1109
1103
. 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 ) )
1111
1105
. collect ( ) ;
1106
+ source_file_hashes. sort_unstable_by_key ( |& ( name_hash, _) | name_hash) ;
1112
1107
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 ) > {
1144
1108
let mut upstream_crates: Vec < _ > = tcx
1145
1109
. crates ( ( ) )
1146
1110
. iter ( )
@@ -1151,7 +1115,20 @@ fn upstream_crates(tcx: TyCtxt<'_>) -> Vec<(StableCrateId, Svh)> {
1151
1115
} )
1152
1116
. collect ( ) ;
1153
1117
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 ( ) )
1155
1132
}
1156
1133
1157
1134
fn hir_id_to_string ( map : Map < ' _ > , id : HirId ) -> String {
0 commit comments