diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-04-05 22:09:49 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-05-07 21:42:42 +0200 |
| commit | 1891da0378131ae68a41021075aa7c2034a4b8a5 (patch) | |
| tree | 705d1689b8959e3add07ddbaabf817144b2348d0 /compiler | |
| parent | ca712bc4255cd0912e00ec2eee5b6a547385c2b0 (diff) | |
| download | rust-1891da0378131ae68a41021075aa7c2034a4b8a5.tar.gz rust-1891da0378131ae68a41021075aa7c2034a4b8a5.zip | |
Hash attributes as part of the crate hash.
Diffstat (limited to 'compiler')
| -rw-r--r-- | compiler/rustc_middle/src/hir/map/mod.rs | 13 |
1 files changed, 9 insertions, 4 deletions
diff --git a/compiler/rustc_middle/src/hir/map/mod.rs b/compiler/rustc_middle/src/hir/map/mod.rs index 73f3b550c37..09736c6f1e5 100644 --- a/compiler/rustc_middle/src/hir/map/mod.rs +++ b/compiler/rustc_middle/src/hir/map/mod.rs @@ -1,6 +1,6 @@ use self::collector::NodeCollector; -use crate::hir::{HirOwnerData, IndexedHir}; +use crate::hir::{AttributeMap, HirOwnerData, IndexedHir}; use crate::middle::cstore::CrateStore; use crate::ty::TyCtxt; use rustc_ast as ast; @@ -943,14 +943,19 @@ pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx Indexe } pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { + let mut hcx = tcx.create_stable_hashing_context(); + let mut hir_body_nodes: Vec<_> = tcx .index_hir(crate_num) .map .iter_enumerated() .filter_map(|(def_id, hod)| { let def_path_hash = tcx.definitions.def_path_hash(def_id); - let hash = hod.with_bodies.as_ref()?.hash; - Some((def_path_hash, hash)) + let mut hasher = StableHasher::new(); + hod.with_bodies.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())) }) .collect(); hir_body_nodes.sort_unstable_by_key(|bn| bn.0); @@ -980,13 +985,13 @@ pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh { source_file_names.sort_unstable(); - let mut hcx = tcx.create_stable_hashing_context(); let mut stable_hasher = StableHasher::new(); node_hashes.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); tcx.sess.local_crate_disambiguator().to_fingerprint().hash_stable(&mut hcx, &mut stable_hasher); + tcx.untracked_crate.non_exported_macro_attrs.hash_stable(&mut hcx, &mut stable_hasher); let crate_hash: Fingerprint = stable_hasher.finish(); Svh::new(crate_hash.to_smaller_hash()) |
