Skip to content

Only store a LocalDefId in some HIR nodes #81611

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 14 commits into from
Feb 17, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Remove HirItemLike.
  • Loading branch information
cjgillot committed Feb 15, 2021
commit 91d8e59ccaacf7df2af847037d30871ed0bd90b6
32 changes: 7 additions & 25 deletions compiler/rustc_middle/src/hir/map/collector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,22 +55,19 @@ fn insert_vec_map<K: Idx, V: Clone>(map: &mut IndexVec<K, Option<V>>, k: K, v: V
map[k] = Some(v);
}

fn hash(
hcx: &mut StableHashingContext<'_>,
input: impl for<'a> HashStable<StableHashingContext<'a>>,
) -> Fingerprint {
let mut stable_hasher = StableHasher::new();
input.hash_stable(hcx, &mut stable_hasher);
stable_hasher.finish()
}

fn hash_body(
hcx: &mut StableHashingContext<'_>,
def_path_hash: DefPathHash,
item_like: impl for<'a> HashStable<StableHashingContext<'a>>,
hir_body_nodes: &mut Vec<(DefPathHash, Fingerprint)>,
) -> Fingerprint {
let hash = hash(hcx, HirItemLike { item_like: &item_like });
let hash = {
let mut stable_hasher = StableHasher::new();
hcx.while_hashing_hir_bodies(true, |hcx| {
item_like.hash_stable(hcx, &mut stable_hasher);
});
stable_hasher.finish()
};
hir_body_nodes.push((def_path_hash, hash));
hash
}
Expand Down Expand Up @@ -575,18 +572,3 @@ impl<'a, 'hir> Visitor<'hir> for NodeCollector<'a, 'hir> {
self.visit_nested_foreign_item(id);
}
}

struct HirItemLike<T> {
item_like: T,
}

impl<'hir, T> HashStable<StableHashingContext<'hir>> for HirItemLike<T>
where
T: HashStable<StableHashingContext<'hir>>,
{
fn hash_stable(&self, hcx: &mut StableHashingContext<'hir>, hasher: &mut StableHasher) {
hcx.while_hashing_hir_bodies(true, |hcx| {
self.item_like.hash_stable(hcx, hasher);
});
}
}