diff options
| author | Jubilee <46493976+workingjubilee@users.noreply.github.com> | 2021-10-07 20:26:14 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2021-10-07 20:26:14 -0700 |
| commit | aed18018410ea09de7924938e15f877bc3df4a71 (patch) | |
| tree | 206bcbd5321df8c11357551346c286ac30ca270a /compiler/rustc_query_impl/src/on_disk_cache.rs | |
| parent | 1c1c6eda94e9841d0a534ba012034b05173c6a13 (diff) | |
| parent | 4028b093e468afad4896a1658924e3e3f3b8f57c (diff) | |
| download | rust-aed18018410ea09de7924938e15f877bc3df4a71.tar.gz rust-aed18018410ea09de7924938e15f877bc3df4a71.zip | |
Rollup merge of #89476 - cjgillot:expn-id, r=petrochenkov
Correct decoding of foreign expansions during incr. comp. Fixes https://github.com/rust-lang/rust/issues/74946 The original issue was due to a wrong assertion in `expn_hash_to_expn_id`. The secondary issue was due to a mismatch between the encoding and decoding paths for expansions that are created after the TyCtxt is created.
Diffstat (limited to 'compiler/rustc_query_impl/src/on_disk_cache.rs')
| -rw-r--r-- | compiler/rustc_query_impl/src/on_disk_cache.rs | 34 |
1 files changed, 22 insertions, 12 deletions
diff --git a/compiler/rustc_query_impl/src/on_disk_cache.rs b/compiler/rustc_query_impl/src/on_disk_cache.rs index d8cff0bd188..48eb488792d 100644 --- a/compiler/rustc_query_impl/src/on_disk_cache.rs +++ b/compiler/rustc_query_impl/src/on_disk_cache.rs @@ -664,22 +664,32 @@ 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(krate, index_guess, hash) + decoder.tcx.cstore_untracked().expn_hash_to_expn_id( + decoder.tcx.sess, + krate, + index_guess, + 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); - } - + debug_assert_eq!(expn_id.krate, krate); Ok(expn_id) } } |
