diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2021-07-10 23:34:41 +0200 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-07-17 19:35:33 +0200 |
| commit | 6e78d6c9d697217998322ab626cbeee24cdfe228 (patch) | |
| tree | 0f6242e82240bc69adb48880344da2fcd555c5ab /compiler/rustc_middle | |
| parent | c2d43e132975126dda1364346db8498fbc3917b0 (diff) | |
| download | rust-6e78d6c9d697217998322ab626cbeee24cdfe228.tar.gz rust-6e78d6c9d697217998322ab626cbeee24cdfe228.zip | |
Make the CrateNum part of the ExpnId.
Diffstat (limited to 'compiler/rustc_middle')
| -rw-r--r-- | compiler/rustc_middle/src/middle/cstore.rs | 6 | ||||
| -rw-r--r-- | compiler/rustc_middle/src/ty/query/on_disk_cache.rs | 12 |
2 files changed, 13 insertions, 5 deletions
diff --git a/compiler/rustc_middle/src/middle/cstore.rs b/compiler/rustc_middle/src/middle/cstore.rs index 7efe8e061e8..c10fcc2e90c 100644 --- a/compiler/rustc_middle/src/middle/cstore.rs +++ b/compiler/rustc_middle/src/middle/cstore.rs @@ -6,12 +6,13 @@ use crate::ty::TyCtxt; use rustc_ast as ast; use rustc_data_structures::sync::{self, MetadataRef}; -use rustc_hir::def_id::{CrateNum, DefId, LOCAL_CRATE}; +use rustc_hir::def_id::{CrateNum, DefId, StableCrateId, LOCAL_CRATE}; use rustc_hir::definitions::{DefKey, DefPath, DefPathHash}; use rustc_macros::HashStable; use rustc_session::search_paths::PathKind; use rustc_session::utils::NativeLibKind; -use rustc_session::StableCrateId; +use rustc_session::Session; +use rustc_span::hygiene::{ExpnData, ExpnHash, ExpnId}; use rustc_span::symbol::Symbol; use rustc_span::Span; use rustc_target::spec::Target; @@ -187,6 +188,7 @@ pub type MetadataLoaderDyn = dyn MetadataLoader + Sync; /// during resolve) pub trait CrateStore: std::fmt::Debug { fn as_any(&self) -> &dyn Any; + fn decode_expn_data(&self, sess: &Session, expn_id: ExpnId) -> (ExpnData, ExpnHash); // Foreign definitions. // This information is safe to access, since it's hashed as part of the DefPathHash, which incr. diff --git a/compiler/rustc_middle/src/ty/query/on_disk_cache.rs b/compiler/rustc_middle/src/ty/query/on_disk_cache.rs index 85e84d6a0f4..358d016368e 100644 --- a/compiler/rustc_middle/src/ty/query/on_disk_cache.rs +++ b/compiler/rustc_middle/src/ty/query/on_disk_cache.rs @@ -364,9 +364,12 @@ impl<'sess> OnDiskCache<'sess> { Ok(()) }, |encoder, index, expn_data, hash| -> FileEncodeResult { - let pos = AbsoluteBytePos::new(encoder.position()); - encoder.encode_tagged(TAG_EXPN_DATA, &(expn_data, hash))?; - expn_ids.insert(index, pos); + if index.krate == LOCAL_CRATE { + let pos = AbsoluteBytePos::new(encoder.position()); + encoder.encode_tagged(TAG_EXPN_DATA, &(expn_data, hash))?; + expn_ids.insert(index.local_id.as_u32(), pos); + } + // TODO Handle foreign expansions. Ok(()) }, )?; @@ -807,6 +810,9 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for ExpnId { Ok(data) }) }, + |this, expn_id| { + Ok(this.tcx.untracked_resolutions.cstore.decode_expn_data(this.tcx.sess, expn_id)) + }, ) } } |
