Make QueryAccessor::dep_kind an associated const.
This commit is contained in:
parent
0bf5cae489
commit
fc82376bc4
2 changed files with 6 additions and 11 deletions
|
|
@ -28,6 +28,7 @@ pub trait QueryConfig<'tcx> {
|
|||
pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
|
||||
const ANON: bool;
|
||||
const EVAL_ALWAYS: bool;
|
||||
const DEP_KIND: DepKind;
|
||||
|
||||
type Cache: QueryCache<Self::Key, Self::Value>;
|
||||
|
||||
|
|
@ -38,8 +39,6 @@ pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
|
|||
|
||||
fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode;
|
||||
|
||||
fn dep_kind() -> DepKind;
|
||||
|
||||
// Don't use this method to compute query results, instead use the methods on TyCtxt
|
||||
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value;
|
||||
|
||||
|
|
|
|||
|
|
@ -154,7 +154,7 @@ impl<'tcx, Q: QueryDescription<'tcx>> JobOwner<'tcx, Q> {
|
|||
};
|
||||
|
||||
// Create the id of the job we're waiting for
|
||||
let id = QueryJobId::new(job.id, lookup.shard, Q::dep_kind());
|
||||
let id = QueryJobId::new(job.id, lookup.shard, Q::DEP_KIND);
|
||||
|
||||
(job.latch(id), _query_blocked_prof_timer)
|
||||
}
|
||||
|
|
@ -169,7 +169,7 @@ impl<'tcx, Q: QueryDescription<'tcx>> JobOwner<'tcx, Q> {
|
|||
lock.jobs = id;
|
||||
let id = QueryShardJobId(NonZeroU32::new(id).unwrap());
|
||||
|
||||
let global_id = QueryJobId::new(id, lookup.shard, Q::dep_kind());
|
||||
let global_id = QueryJobId::new(id, lookup.shard, Q::DEP_KIND);
|
||||
|
||||
let job = tls::with_related_context(tcx, |icx| QueryJob::new(id, span, icx.query));
|
||||
|
||||
|
|
@ -498,7 +498,7 @@ impl<'tcx> TyCtxt<'tcx> {
|
|||
|
||||
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
|
||||
self.start_query(job.id, diagnostics, |tcx| {
|
||||
tcx.dep_graph.with_anon_task(Q::dep_kind(), || Q::compute(tcx, key))
|
||||
tcx.dep_graph.with_anon_task(Q::DEP_KIND, || Q::compute(tcx, key))
|
||||
})
|
||||
});
|
||||
|
||||
|
|
@ -873,7 +873,7 @@ macro_rules! define_queries_inner {
|
|||
job: job.id,
|
||||
shard: u16::try_from(shard_id).unwrap(),
|
||||
kind:
|
||||
<queries::$name<'tcx> as QueryAccessors<'tcx>>::dep_kind(),
|
||||
<queries::$name<'tcx> as QueryAccessors<'tcx>>::DEP_KIND,
|
||||
};
|
||||
let info = QueryInfo {
|
||||
span: job.span,
|
||||
|
|
@ -961,6 +961,7 @@ macro_rules! define_queries_inner {
|
|||
impl<$tcx> QueryAccessors<$tcx> for queries::$name<$tcx> {
|
||||
const ANON: bool = is_anon!([$($modifiers)*]);
|
||||
const EVAL_ALWAYS: bool = is_eval_always!([$($modifiers)*]);
|
||||
const DEP_KIND: dep_graph::DepKind = dep_graph::DepKind::$node;
|
||||
|
||||
type Cache = query_storage!([$($modifiers)*][$K, $V]);
|
||||
|
||||
|
|
@ -980,11 +981,6 @@ macro_rules! define_queries_inner {
|
|||
DepConstructor::$node(tcx, *key)
|
||||
}
|
||||
|
||||
#[inline(always)]
|
||||
fn dep_kind() -> dep_graph::DepKind {
|
||||
dep_graph::DepKind::$node
|
||||
}
|
||||
|
||||
#[inline]
|
||||
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value {
|
||||
let provider = tcx.queries.providers.get(key.query_crate())
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue