about summary refs log tree commit diff
path: root/compiler/rustc_query_impl/src/on_disk_cache.rs
diff options
context:
space:
mode:
authorCamille GILLOT <gillot.camille@gmail.com>2021-10-02 21:14:52 +0200
committerCamille GILLOT <gillot.camille@gmail.com>2021-10-06 19:10:07 +0200
commitdaf8903e8ed1f4704077e02479f841b84ebc82d3 (patch)
tree6384a71ac1887533d317b460e28f087609afe049 /compiler/rustc_query_impl/src/on_disk_cache.rs
parentce21756ed3acdd6bb4c222725214c24e1bc70915 (diff)
downloadrust-daf8903e8ed1f4704077e02479f841b84ebc82d3.tar.gz
rust-daf8903e8ed1f4704077e02479f841b84ebc82d3.zip
Do not re-hash foreign spans.
Diffstat (limited to 'compiler/rustc_query_impl/src/on_disk_cache.rs')
-rw-r--r--compiler/rustc_query_impl/src/on_disk_cache.rs27
1 files changed, 16 insertions, 11 deletions
diff --git a/compiler/rustc_query_impl/src/on_disk_cache.rs b/compiler/rustc_query_impl/src/on_disk_cache.rs
index f93623e445c..48eb488792d 100644
--- a/compiler/rustc_query_impl/src/on_disk_cache.rs
+++ b/compiler/rustc_query_impl/src/on_disk_cache.rs
@@ -664,7 +664,21 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for ExpnId {
 
             let data: ExpnData = decoder
                 .with_position(pos.to_usize(), |decoder| decode_tagged(decoder, TAG_EXPN_DATA))?;
-            rustc_span::hygiene::register_local_expn_id(data, hash)
+            let expn_id = rustc_span::hygiene::register_local_expn_id(data, hash);
+
+            #[cfg(debug_assertions)]
+            {
+                use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
+                let mut hcx = decoder.tcx.create_stable_hashing_context();
+                let mut hasher = StableHasher::new();
+                hcx.while_hashing_spans(true, |hcx| {
+                    expn_id.expn_data().hash_stable(hcx, &mut hasher)
+                });
+                let local_hash: u64 = hasher.finish();
+                debug_assert_eq!(hash.local_hash(), local_hash);
+            }
+
+            expn_id
         } else {
             let index_guess = decoder.foreign_expn_data[&hash];
             decoder.tcx.cstore_untracked().expn_hash_to_expn_id(
@@ -675,16 +689,7 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for ExpnId {
             )
         };
 
-        #[cfg(debug_assertions)]
-        {
-            use rustc_data_structures::stable_hasher::{HashStable, StableHasher};
-            let mut hcx = decoder.tcx.create_stable_hashing_context();
-            let mut hasher = StableHasher::new();
-            hcx.while_hashing_spans(true, |hcx| expn_id.expn_data().hash_stable(hcx, &mut hasher));
-            let local_hash: u64 = hasher.finish();
-            debug_assert_eq!(hash.local_hash(), local_hash);
-        }
-
+        debug_assert_eq!(expn_id.krate, krate);
         Ok(expn_id)
     }
 }