Auto merge of #123097 - oli-obk:perf_experiment, r=petrochenkov
Try using a `dyn Debug` trait object instead of a closure These closures were introduced in https://github.com/rust-lang/rust/pull/93098 let's see if we can't use fmt::Arguments instead cc `@Aaron1011`
This commit is contained in:
commit
385fa9d845
@ -380,14 +380,19 @@ pub fn create_def(&mut self, parent: LocalDefId, data: DefPathData) -> LocalDefI
|
|||||||
pub fn local_def_path_hash_to_def_id(
|
pub fn local_def_path_hash_to_def_id(
|
||||||
&self,
|
&self,
|
||||||
hash: DefPathHash,
|
hash: DefPathHash,
|
||||||
err: &mut dyn FnMut() -> !,
|
err_msg: &dyn std::fmt::Debug,
|
||||||
) -> LocalDefId {
|
) -> LocalDefId {
|
||||||
debug_assert!(hash.stable_crate_id() == self.table.stable_crate_id);
|
debug_assert!(hash.stable_crate_id() == self.table.stable_crate_id);
|
||||||
|
#[cold]
|
||||||
|
#[inline(never)]
|
||||||
|
fn err(err_msg: &dyn std::fmt::Debug) -> ! {
|
||||||
|
panic!("{err_msg:?}")
|
||||||
|
}
|
||||||
self.table
|
self.table
|
||||||
.def_path_hash_to_index
|
.def_path_hash_to_index
|
||||||
.get(&hash.local_hash())
|
.get(&hash.local_hash())
|
||||||
.map(|local_def_index| LocalDefId { local_def_index })
|
.map(|local_def_index| LocalDefId { local_def_index })
|
||||||
.unwrap_or_else(|| err())
|
.unwrap_or_else(|| err(err_msg))
|
||||||
}
|
}
|
||||||
|
|
||||||
pub fn def_path_hash_to_def_index_map(&self) -> &DefPathHashMap {
|
pub fn def_path_hash_to_def_index_map(&self) -> &DefPathHashMap {
|
||||||
|
@ -194,9 +194,10 @@ impl DepNodeExt for DepNode {
|
|||||||
/// has been removed.
|
/// has been removed.
|
||||||
fn extract_def_id(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
|
fn extract_def_id(&self, tcx: TyCtxt<'_>) -> Option<DefId> {
|
||||||
if tcx.fingerprint_style(self.kind) == FingerprintStyle::DefPathHash {
|
if tcx.fingerprint_style(self.kind) == FingerprintStyle::DefPathHash {
|
||||||
Some(tcx.def_path_hash_to_def_id(DefPathHash(self.hash.into()), &mut || {
|
Some(tcx.def_path_hash_to_def_id(
|
||||||
panic!("Failed to extract DefId: {:?} {}", self.kind, self.hash)
|
DefPathHash(self.hash.into()),
|
||||||
}))
|
&("Failed to extract DefId", self.kind, self.hash),
|
||||||
|
))
|
||||||
} else {
|
} else {
|
||||||
None
|
None
|
||||||
}
|
}
|
||||||
@ -390,9 +391,10 @@ fn recover(tcx: TyCtxt<'tcx>, dep_node: &DepNode) -> Option<Self> {
|
|||||||
let (local_hash, local_id) = Fingerprint::from(dep_node.hash).split();
|
let (local_hash, local_id) = Fingerprint::from(dep_node.hash).split();
|
||||||
let def_path_hash = DefPathHash::new(tcx.stable_crate_id(LOCAL_CRATE), local_hash);
|
let def_path_hash = DefPathHash::new(tcx.stable_crate_id(LOCAL_CRATE), local_hash);
|
||||||
let def_id = tcx
|
let def_id = tcx
|
||||||
.def_path_hash_to_def_id(def_path_hash, &mut || {
|
.def_path_hash_to_def_id(
|
||||||
panic!("Failed to extract HirId: {:?} {}", dep_node.kind, dep_node.hash)
|
def_path_hash,
|
||||||
})
|
&("Failed to extract HirId", dep_node.kind, dep_node.hash),
|
||||||
|
)
|
||||||
.expect_local();
|
.expect_local();
|
||||||
let local_id = local_id
|
let local_id = local_id
|
||||||
.as_u64()
|
.as_u64()
|
||||||
|
@ -737,9 +737,10 @@ fn decode_def_id(&mut self) -> DefId {
|
|||||||
// If we get to this point, then all of the query inputs were green,
|
// If we get to this point, then all of the query inputs were green,
|
||||||
// which means that the definition with this hash is guaranteed to
|
// which means that the definition with this hash is guaranteed to
|
||||||
// still exist in the current compilation session.
|
// still exist in the current compilation session.
|
||||||
self.tcx.def_path_hash_to_def_id(def_path_hash, &mut || {
|
self.tcx.def_path_hash_to_def_id(
|
||||||
panic!("Failed to convert DefPathHash {def_path_hash:?}")
|
def_path_hash,
|
||||||
})
|
&("Failed to convert DefPathHash", def_path_hash),
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
fn decode_attr_id(&mut self) -> rustc_span::AttrId {
|
fn decode_attr_id(&mut self) -> rustc_span::AttrId {
|
||||||
|
@ -1121,7 +1121,11 @@ pub fn stable_crate_id_to_crate_num(self, stable_crate_id: StableCrateId) -> Cra
|
|||||||
/// Converts a `DefPathHash` to its corresponding `DefId` in the current compilation
|
/// Converts a `DefPathHash` to its corresponding `DefId` in the current compilation
|
||||||
/// session, if it still exists. This is used during incremental compilation to
|
/// session, if it still exists. This is used during incremental compilation to
|
||||||
/// turn a deserialized `DefPathHash` into its current `DefId`.
|
/// turn a deserialized `DefPathHash` into its current `DefId`.
|
||||||
pub fn def_path_hash_to_def_id(self, hash: DefPathHash, err: &mut dyn FnMut() -> !) -> DefId {
|
pub fn def_path_hash_to_def_id(
|
||||||
|
self,
|
||||||
|
hash: DefPathHash,
|
||||||
|
err_msg: &dyn std::fmt::Debug,
|
||||||
|
) -> DefId {
|
||||||
debug!("def_path_hash_to_def_id({:?})", hash);
|
debug!("def_path_hash_to_def_id({:?})", hash);
|
||||||
|
|
||||||
let stable_crate_id = hash.stable_crate_id();
|
let stable_crate_id = hash.stable_crate_id();
|
||||||
@ -1129,7 +1133,11 @@ pub fn def_path_hash_to_def_id(self, hash: DefPathHash, err: &mut dyn FnMut() ->
|
|||||||
// If this is a DefPathHash from the local crate, we can look up the
|
// If this is a DefPathHash from the local crate, we can look up the
|
||||||
// DefId in the tcx's `Definitions`.
|
// DefId in the tcx's `Definitions`.
|
||||||
if stable_crate_id == self.stable_crate_id(LOCAL_CRATE) {
|
if stable_crate_id == self.stable_crate_id(LOCAL_CRATE) {
|
||||||
self.untracked.definitions.read().local_def_path_hash_to_def_id(hash, err).to_def_id()
|
self.untracked
|
||||||
|
.definitions
|
||||||
|
.read()
|
||||||
|
.local_def_path_hash_to_def_id(hash, err_msg)
|
||||||
|
.to_def_id()
|
||||||
} else {
|
} else {
|
||||||
// If this is a DefPathHash from an upstream crate, let the CrateStore map
|
// If this is a DefPathHash from an upstream crate, let the CrateStore map
|
||||||
// it to a DefId.
|
// it to a DefId.
|
||||||
|
Loading…
Reference in New Issue
Block a user