Skip to content

Commit a73e39c

Browse files
committed
Access Session while decoding expn_id.
1 parent c02371c commit a73e39c

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1623,7 +1623,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16231623
self.def_path_hash_map.def_path_hash_to_def_index(&hash)
16241624
}
16251625

1626-
fn expn_hash_to_expn_id(&self, index_guess: u32, hash: ExpnHash) -> ExpnId {
1626+
fn expn_hash_to_expn_id(&self, sess: &Session, index_guess: u32, hash: ExpnHash) -> ExpnId {
16271627
debug_assert_eq!(ExpnId::from_hash(hash), None);
16281628
let index_guess = ExpnIndex::from_u32(index_guess);
16291629
let old_hash = self.root.expn_hashes.get(self, index_guess).map(|lazy| lazy.decode(self));
@@ -1654,7 +1654,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16541654
map[&hash]
16551655
};
16561656

1657-
let data = self.root.expn_data.get(self, index).unwrap().decode(self);
1657+
let data = self.root.expn_data.get(self, index).unwrap().decode((self, sess));
16581658
rustc_span::hygiene::register_expn_id(self.cnum, index, data, hash)
16591659
}
16601660

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+8-2
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,13 @@ impl CrateStore for CStore {
507507
DefId { krate: cnum, index: def_index }
508508
}
509509

510-
fn expn_hash_to_expn_id(&self, cnum: CrateNum, index_guess: u32, hash: ExpnHash) -> ExpnId {
511-
self.get_crate_data(cnum).expn_hash_to_expn_id(index_guess, hash)
510+
fn expn_hash_to_expn_id(
511+
&self,
512+
sess: &Session,
513+
cnum: CrateNum,
514+
index_guess: u32,
515+
hash: ExpnHash,
516+
) -> ExpnId {
517+
self.get_crate_data(cnum).expn_hash_to_expn_id(sess, index_guess, hash)
512518
}
513519
}

compiler/rustc_middle/src/middle/cstore.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_hir::definitions::{DefKey, DefPath, DefPathHash};
99
use rustc_macros::HashStable;
1010
use rustc_session::search_paths::PathKind;
1111
use rustc_session::utils::NativeLibKind;
12+
use rustc_session::Session;
1213
use rustc_span::hygiene::{ExpnHash, ExpnId};
1314
use rustc_span::symbol::Symbol;
1415
use rustc_span::Span;
@@ -190,7 +191,13 @@ pub trait CrateStore: std::fmt::Debug {
190191

191192
/// Fetch a DefId from a DefPathHash for a foreign crate.
192193
fn def_path_hash_to_def_id(&self, cnum: CrateNum, hash: DefPathHash) -> DefId;
193-
fn expn_hash_to_expn_id(&self, cnum: CrateNum, index_guess: u32, hash: ExpnHash) -> ExpnId;
194+
fn expn_hash_to_expn_id(
195+
&self,
196+
sess: &Session,
197+
cnum: CrateNum,
198+
index_guess: u32,
199+
hash: ExpnHash,
200+
) -> ExpnId;
194201
}
195202

196203
pub type CrateStoreDyn = dyn CrateStore + sync::Sync;

compiler/rustc_query_impl/src/on_disk_cache.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -667,7 +667,12 @@ impl<'a, 'tcx> Decodable<CacheDecoder<'a, 'tcx>> for ExpnId {
667667
rustc_span::hygiene::register_local_expn_id(data, hash)
668668
} else {
669669
let index_guess = decoder.foreign_expn_data[&hash];
670-
decoder.tcx.cstore_untracked().expn_hash_to_expn_id(krate, index_guess, hash)
670+
decoder.tcx.cstore_untracked().expn_hash_to_expn_id(
671+
decoder.tcx.sess,
672+
krate,
673+
index_guess,
674+
hash,
675+
)
671676
};
672677

673678
#[cfg(debug_assertions)]

0 commit comments

Comments
 (0)