1
Fork 0

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:
bors 2024-04-04 20:52:52 +00:00
commit 385fa9d845
4 changed files with 29 additions and 13 deletions

View file

@ -380,14 +380,19 @@ impl Definitions {
pub fn local_def_path_hash_to_def_id(
&self,
hash: DefPathHash,
err: &mut dyn FnMut() -> !,
err_msg: &dyn std::fmt::Debug,
) -> LocalDefId {
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
.def_path_hash_to_index
.get(&hash.local_hash())
.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 {