Skip to content

Commit 1891da0

Browse files
committed
Hash attributes as part of the crate hash.
1 parent ca712bc commit 1891da0

File tree

1 file changed

+9
-4
lines changed
  • compiler/rustc_middle/src/hir/map

1 file changed

+9
-4
lines changed

compiler/rustc_middle/src/hir/map/mod.rs

+9-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use self::collector::NodeCollector;
22

3-
use crate::hir::{HirOwnerData, IndexedHir};
3+
use crate::hir::{AttributeMap, HirOwnerData, IndexedHir};
44
use crate::middle::cstore::CrateStore;
55
use crate::ty::TyCtxt;
66
use rustc_ast as ast;
@@ -943,14 +943,19 @@ pub(super) fn index_hir<'tcx>(tcx: TyCtxt<'tcx>, cnum: CrateNum) -> &'tcx Indexe
943943
}
944944

945945
pub(super) fn crate_hash(tcx: TyCtxt<'_>, crate_num: CrateNum) -> Svh {
946+
let mut hcx = tcx.create_stable_hashing_context();
947+
946948
let mut hir_body_nodes: Vec<_> = tcx
947949
.index_hir(crate_num)
948950
.map
949951
.iter_enumerated()
950952
.filter_map(|(def_id, hod)| {
951953
let def_path_hash = tcx.definitions.def_path_hash(def_id);
952-
let hash = hod.with_bodies.as_ref()?.hash;
953-
Some((def_path_hash, hash))
954+
let mut hasher = StableHasher::new();
955+
hod.with_bodies.as_ref()?.hash_stable(&mut hcx, &mut hasher);
956+
AttributeMap { map: &tcx.untracked_crate.attrs, prefix: def_id }
957+
.hash_stable(&mut hcx, &mut hasher);
958+
Some((def_path_hash, hasher.finish()))
954959
})
955960
.collect();
956961
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 {
980985

981986
source_file_names.sort_unstable();
982987

983-
let mut hcx = tcx.create_stable_hashing_context();
984988
let mut stable_hasher = StableHasher::new();
985989
node_hashes.hash_stable(&mut hcx, &mut stable_hasher);
986990
upstream_crates.hash_stable(&mut hcx, &mut stable_hasher);
987991
source_file_names.hash_stable(&mut hcx, &mut stable_hasher);
988992
tcx.sess.opts.dep_tracking_hash(true).hash_stable(&mut hcx, &mut stable_hasher);
989993
tcx.sess.local_crate_disambiguator().to_fingerprint().hash_stable(&mut hcx, &mut stable_hasher);
994+
tcx.untracked_crate.non_exported_macro_attrs.hash_stable(&mut hcx, &mut stable_hasher);
990995

991996
let crate_hash: Fingerprint = stable_hasher.finish();
992997
Svh::new(crate_hash.to_smaller_hash())

0 commit comments

Comments
 (0)