diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-05-02 12:16:59 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-09-10 20:18:31 +0200 |
| commit | 6f782c4e114c2913d5f3e8034664852e7b36452a (patch) | |
| tree | 1ef3e7cf434f964e9bd96f51f7e2abb43d924cfd | |
| parent | fb5ced0fbd7625316ee28d4f2f7230aac35753dd (diff) | |
| download | rust-6f782c4e114c2913d5f3e8034664852e7b36452a.tar.gz rust-6f782c4e114c2913d5f3e8034664852e7b36452a.zip | |
Add actual spans to the crate hash.
Now that we encode spans relative to the items, the item's own span is never actually hashed as part of the HIR. In consequence, we explicitly include it in the crate hash to avoid missing cross-crate invalidations.
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 26 |
1 files changed, 13 insertions, 13 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index e0b6039fe34..10714a4b706 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -969,22 +969,12 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { .iter_enumerated() .filter_map(|(def_id, hod)| { let def_path_hash = tcx.untracked_resolutions.definitions.def_path_hash(def_id); - let mut hasher = StableHasher::new(); - hod.as_ref()?.hash_stable(&mut hcx, &mut hasher); - AttributeMap { map: &tcx.untracked_crate.attrs, prefix: def_id } - .hash_stable(&mut hcx, &mut hasher); - Some((def_path_hash, hasher.finish())) + let hash = hod.as_ref()?.hash; + Some((def_path_hash, hash, def_id)) }) .collect(); hir_body_nodes.sort_unstable_by_key(|bn| bn.0); - let node_hashes = hir_body_nodes.iter().fold( - Fingerprint::ZERO, - |combined_fingerprint, &(def_path_hash, fingerprint)| { - combined_fingerprint.combine(def_path_hash.0.combine(fingerprint)) - }, - ); - let upstream_crates = upstream_crates(tcx); // We hash the final, remapped names of all local source files so we @@ -1004,7 +994,17 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { source_file_names.sort_unstable(); let mut stable_hasher = StableHasher::new(); - node_hashes.hash_stable(&mut hcx, &mut stable_hasher); + for (def_path_hash, fingerprint, def_id) in hir_body_nodes.iter() { + def_path_hash.0.hash_stable(&mut hcx, &mut stable_hasher); + fingerprint.hash_stable(&mut hcx, &mut stable_hasher); + AttributeMap { map: &tcx.untracked_crate.attrs, prefix: *def_id } + .hash_stable(&mut hcx, &mut stable_hasher); + if tcx.sess.opts.debugging_opts.incremental_relative_spans { + let span = tcx.untracked_resolutions.definitions.def_span(*def_id); + debug_assert_eq!(span.parent(), None); + span.hash_stable(&mut hcx, &mut stable_hasher); + } + } upstream_crates.hash_stable(&mut hcx, &mut stable_hasher); source_file_names.hash_stable(&mut hcx, &mut stable_hasher); tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher); |
