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_metadata | |
| 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_metadata')
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs | 10 |
2 files changed, 10 insertions, 6 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder.rs b/compiler/rustc_metadata/src/rmeta/decoder.rs index c7d0f594f01..89bb5797a82 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder.rs @@ -1632,7 +1632,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { self.def_path_hash_map.def_path_hash_to_def_index(&hash) } - fn expn_hash_to_expn_id(&self, index_guess: u32, hash: ExpnHash) -> ExpnId { + fn expn_hash_to_expn_id(&self, sess: &Session, index_guess: u32, hash: ExpnHash) -> ExpnId { debug_assert_eq!(ExpnId::from_hash(hash), None); let index_guess = ExpnIndex::from_u32(index_guess); let old_hash = self.root.expn_hashes.get(self, index_guess).map(|lazy| lazy.decode(self)); @@ -1654,8 +1654,6 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { let i = ExpnIndex::from_u32(i); if let Some(hash) = self.root.expn_hashes.get(self, i) { map.insert(hash.decode(self), i); - } else { - panic!("Missing expn_hash entry for {:?}", i); } } map @@ -1663,7 +1661,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> { map[&hash] }; - let data = self.root.expn_data.get(self, index).unwrap().decode(self); + let data = self.root.expn_data.get(self, index).unwrap().decode((self, sess)); rustc_span::hygiene::register_expn_id(self.cnum, index, data, hash) } diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs index 292ef03d856..4e7f85d2c37 100644 --- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs +++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs @@ -506,7 +506,13 @@ impl CrateStore for CStore { DefId { krate: cnum, index: def_index } } - fn expn_hash_to_expn_id(&self, cnum: CrateNum, index_guess: u32, hash: ExpnHash) -> ExpnId { - self.get_crate_data(cnum).expn_hash_to_expn_id(index_guess, hash) + fn expn_hash_to_expn_id( + &self, + sess: &Session, + cnum: CrateNum, + index_guess: u32, + hash: ExpnHash, + ) -> ExpnId { + self.get_crate_data(cnum).expn_hash_to_expn_id(sess, index_guess, hash) } } |
