Skip to content

Commit ce21756

Browse files
committed
Access Session while decoding expn_id.
1 parent 25ec827 commit ce21756

File tree

4 files changed

+24
-6
lines changed

4 files changed

+24
-6
lines changed

compiler/rustc_metadata/src/rmeta/decoder.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1624,7 +1624,7 @@ impl<'a, 'tcx> CrateMetadataRef<'a> {
16241624
self.def_path_hash_map.def_path_hash_to_def_index(&hash)
16251625
}
16261626

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

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

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

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -506,7 +506,13 @@ impl CrateStore for CStore {
506506
DefId { krate: cnum, index: def_index }
507507
}
508508

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

compiler/rustc_query_impl/src/on_disk_cache.rs

Lines changed: 6 additions & 1 deletion
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)]

compiler/rustc_session/src/cstore.rs

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
55
use crate::search_paths::PathKind;
66
use crate::utils::NativeLibKind;
7+
use crate::Session;
78
use rustc_ast as ast;
89
use rustc_data_structures::sync::{self, MetadataRef};
910
use rustc_hir::def_id::{CrateNum, DefId, StableCrateId, LOCAL_CRATE};
@@ -193,7 +194,13 @@ pub trait CrateStore: std::fmt::Debug {
193194

194195
/// Fetch a DefId from a DefPathHash for a foreign crate.
195196
fn def_path_hash_to_def_id(&self, cnum: CrateNum, hash: DefPathHash) -> DefId;
196-
fn expn_hash_to_expn_id(&self, cnum: CrateNum, index_guess: u32, hash: ExpnHash) -> ExpnId;
197+
fn expn_hash_to_expn_id(
198+
&self,
199+
sess: &Session,
200+
cnum: CrateNum,
201+
index_guess: u32,
202+
hash: ExpnHash,
203+
) -> ExpnId;
197204
}
198205

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

0 commit comments

Comments
 (0)