1
Fork 0

Use DepKind instead of &str

This commit is contained in:
gimbles 2022-12-23 18:39:49 +05:30
parent fd02567705
commit f8b30084ac
7 changed files with 141 additions and 114 deletions

View file

@ -66,7 +66,7 @@ impl QueryContext for QueryCtxt<'_> {
tls::with_related_context(**self, |icx| icx.query)
}
fn try_collect_active_jobs(&self) -> Option<QueryMap> {
fn try_collect_active_jobs(&self) -> Option<QueryMap<DepKind>> {
self.queries.try_collect_active_jobs(**self)
}
@ -195,7 +195,7 @@ impl<'tcx> QueryCtxt<'tcx> {
#[derive(Clone, Copy)]
pub(crate) struct QueryStruct<'tcx> {
pub try_collect_active_jobs: fn(QueryCtxt<'tcx>, &mut QueryMap) -> Option<()>,
pub try_collect_active_jobs: fn(QueryCtxt<'tcx>, &mut QueryMap<DepKind>) -> Option<()>,
pub alloc_self_profile_query_strings: fn(TyCtxt<'tcx>, &mut QueryKeyStringCache),
pub encode_query_results:
Option<fn(QueryCtxt<'tcx>, &mut CacheEncoder<'_, 'tcx>, &mut EncodedDepNodeIndex)>,
@ -313,7 +313,7 @@ pub(crate) fn create_query_frame<
key: K,
kind: DepKind,
name: &'static str,
) -> QueryStackFrame {
) -> QueryStackFrame<DepKind> {
// Disable visible paths printing for performance reasons.
// Showing visible path instead of any path is not that important in production.
let description = ty::print::with_no_visible_paths!(
@ -346,7 +346,7 @@ pub(crate) fn create_query_frame<
};
let ty_adt_id = key.ty_adt_id();
QueryStackFrame::new(name, description, span, def_id, def_kind, ty_adt_id, hash)
QueryStackFrame::new(description, span, def_id, def_kind, kind, ty_adt_id, hash)
}
fn try_load_from_on_disk_cache<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode)
@ -378,7 +378,7 @@ fn force_from_dep_node<'tcx, Q>(tcx: TyCtxt<'tcx>, dep_node: DepNode) -> bool
where
Q: QueryConfig<QueryCtxt<'tcx>>,
Q::Key: DepNodeParams<TyCtxt<'tcx>>,
Q::Value: Value<TyCtxt<'tcx>>,
Q::Value: Value<TyCtxt<'tcx>, DepKind>,
{
// We must avoid ever having to call `force_from_dep_node()` for a
// `DepNode::codegen_unit`:
@ -402,7 +402,7 @@ where
#[cfg(debug_assertions)]
let _guard = tracing::span!(tracing::Level::TRACE, stringify!($name), ?key).entered();
let tcx = QueryCtxt::from_tcx(tcx);
force_query::<Q, _>(tcx, key, dep_node);
force_query::<Q, _, DepKind>(tcx, key, dep_node);
true
} else {
false
@ -480,7 +480,7 @@ macro_rules! define_queries {
type Cache = query_storage::$name<'tcx>;
#[inline(always)]
fn query_state<'a>(tcx: QueryCtxt<'tcx>) -> &'a QueryState<Self::Key>
fn query_state<'a>(tcx: QueryCtxt<'tcx>) -> &'a QueryState<Self::Key, crate::dep_graph::DepKind>
where QueryCtxt<'tcx>: 'a
{
&tcx.queries.$name
@ -587,9 +587,10 @@ macro_rules! define_queries {
use $crate::plumbing::{QueryStruct, QueryCtxt};
use $crate::profiling_support::QueryKeyStringCache;
use rustc_query_system::query::QueryMap;
use rustc_middle::dep_graph::DepKind;
pub(super) const fn dummy_query_struct<'tcx>() -> QueryStruct<'tcx> {
fn noop_try_collect_active_jobs(_: QueryCtxt<'_>, _: &mut QueryMap) -> Option<()> {
fn noop_try_collect_active_jobs(_: QueryCtxt<'_>, _: &mut QueryMap<DepKind>) -> Option<()> {
None
}
fn noop_alloc_self_profile_query_strings(_: TyCtxt<'_>, _: &mut QueryKeyStringCache) {}
@ -675,7 +676,8 @@ macro_rules! define_queries_struct {
$(
$(#[$attr])*
$name: QueryState<
<queries::$name<'tcx> as QueryConfig<QueryCtxt<'tcx>>>::Key
<queries::$name<'tcx> as QueryConfig<QueryCtxt<'tcx>>>::Key,
rustc_middle::dep_graph::DepKind,
>,
)*
}
@ -684,7 +686,7 @@ macro_rules! define_queries_struct {
pub(crate) fn try_collect_active_jobs(
&'tcx self,
tcx: TyCtxt<'tcx>,
) -> Option<QueryMap> {
) -> Option<QueryMap<rustc_middle::dep_graph::DepKind>> {
let tcx = QueryCtxt { tcx, queries: self };
let mut jobs = QueryMap::default();
@ -718,7 +720,7 @@ macro_rules! define_queries_struct {
mode: QueryMode,
) -> Option<query_stored::$name<'tcx>> {
let qcx = QueryCtxt { tcx, queries: self };
get_query::<queries::$name<'tcx>, _>(qcx, span, key, mode)
get_query::<queries::$name<'tcx>, _, rustc_middle::dep_graph::DepKind>(qcx, span, key, mode)
})*
}
};