Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit fc82376

Browse files
committed
Make QueryAccessor::dep_kind an associated const.
1 parent 0bf5cae commit fc82376

File tree

2 files changed

+6
-11
lines changed

2 files changed

+6
-11
lines changed

src/librustc/ty/query/config.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ pub trait QueryConfig<'tcx> {
2828
pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
2929
const ANON: bool;
3030
const EVAL_ALWAYS: bool;
31+
const DEP_KIND: DepKind;
3132

3233
type Cache: QueryCache<Self::Key, Self::Value>;
3334

@@ -38,8 +39,6 @@ pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
3839

3940
fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode;
4041

41-
fn dep_kind() -> DepKind;
42-
4342
// Don't use this method to compute query results, instead use the methods on TyCtxt
4443
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value;
4544

src/librustc/ty/query/plumbing.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ impl<'tcx, Q: QueryDescription<'tcx>> JobOwner<'tcx, Q> {
154154
};
155155

156156
// Create the id of the job we're waiting for
157-
let id = QueryJobId::new(job.id, lookup.shard, Q::dep_kind());
157+
let id = QueryJobId::new(job.id, lookup.shard, Q::DEP_KIND);
158158

159159
(job.latch(id), _query_blocked_prof_timer)
160160
}
@@ -169,7 +169,7 @@ impl<'tcx, Q: QueryDescription<'tcx>> JobOwner<'tcx, Q> {
169169
lock.jobs = id;
170170
let id = QueryShardJobId(NonZeroU32::new(id).unwrap());
171171

172-
let global_id = QueryJobId::new(id, lookup.shard, Q::dep_kind());
172+
let global_id = QueryJobId::new(id, lookup.shard, Q::DEP_KIND);
173173

174174
let job = tls::with_related_context(tcx, |icx| QueryJob::new(id, span, icx.query));
175175

@@ -498,7 +498,7 @@ impl<'tcx> TyCtxt<'tcx> {
498498

499499
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
500500
self.start_query(job.id, diagnostics, |tcx| {
501-
tcx.dep_graph.with_anon_task(Q::dep_kind(), || Q::compute(tcx, key))
501+
tcx.dep_graph.with_anon_task(Q::DEP_KIND, || Q::compute(tcx, key))
502502
})
503503
});
504504

@@ -873,7 +873,7 @@ macro_rules! define_queries_inner {
873873
job: job.id,
874874
shard: u16::try_from(shard_id).unwrap(),
875875
kind:
876-
<queries::$name<'tcx> as QueryAccessors<'tcx>>::dep_kind(),
876+
<queries::$name<'tcx> as QueryAccessors<'tcx>>::DEP_KIND,
877877
};
878878
let info = QueryInfo {
879879
span: job.span,
@@ -961,6 +961,7 @@ macro_rules! define_queries_inner {
961961
impl<$tcx> QueryAccessors<$tcx> for queries::$name<$tcx> {
962962
const ANON: bool = is_anon!([$($modifiers)*]);
963963
const EVAL_ALWAYS: bool = is_eval_always!([$($modifiers)*]);
964+
const DEP_KIND: dep_graph::DepKind = dep_graph::DepKind::$node;
964965

965966
type Cache = query_storage!([$($modifiers)*][$K, $V]);
966967

@@ -980,11 +981,6 @@ macro_rules! define_queries_inner {
980981
DepConstructor::$node(tcx, *key)
981982
}
982983

983-
#[inline(always)]
984-
fn dep_kind() -> dep_graph::DepKind {
985-
dep_graph::DepKind::$node
986-
}
987-
988984
#[inline]
989985
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value {
990986
let provider = tcx.queries.providers.get(key.query_crate())

0 commit comments

Comments
 (0)