Don't create a new try_load_from_disk closure for each query

Instead, define a single function, parameterized only by the return type.
This commit is contained in:
Joshua Nelson 2022-09-01 22:20:17 -05:00
parent 112419c9f0
commit b164dbc271
3 changed files with 27 additions and 2 deletions

View file

@ -255,7 +255,7 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
}
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
= Some(|tcx, id| tcx.on_disk_cache().as_ref()?.try_load_query_result(*tcx, id));
= Some(crate::plumbing::try_load_from_disk::<Self::Value>);
}
} else {
quote! {