Skip to content

Commit

Permalink
Auto merge of rust-lang#78415 - tgnottingham:expn_id_tag_hash, r=Aaro…
Browse files Browse the repository at this point in the history
…n1011

rustc_span: avoid hashing ExpnId tag when using cached hash
  • Loading branch information
bors committed Oct 28, 2020
2 parents 3dddf6a + a3623e0 commit 31ee872
Showing 1 changed file with 1 addition and 2 deletions.
3 changes: 1 addition & 2 deletions compiler/rustc_span/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1925,9 +1925,7 @@ impl<CTX: HashStableContext> HashStable<CTX> for ExpnId {
return;
}

TAG_NOT_ROOT.hash_stable(ctx, hasher);
let index = self.as_u32() as usize;

let res = CACHE.with(|cache| cache.borrow().get(index).copied().flatten());

if let Some(res) = res {
Expand All @@ -1936,6 +1934,7 @@ impl<CTX: HashStableContext> HashStable<CTX> for ExpnId {
let new_len = index + 1;

let mut sub_hasher = StableHasher::new();
TAG_NOT_ROOT.hash_stable(ctx, &mut sub_hasher);
self.expn_data().hash_stable(ctx, &mut sub_hasher);
let sub_hash: Fingerprint = sub_hasher.finish();

Expand Down

0 comments on commit 31ee872

Please sign in to comment.