Skip to content

Commit 1f8725c

Browse files
committed
Make QueryAccessor::dep_kind an associated const.
1 parent 26997d1 commit 1f8725c

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
@@ -29,6 +29,7 @@ pub trait QueryConfig<'tcx> {
2929
pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
3030
const ANON: bool;
3131
const EVAL_ALWAYS: bool;
32+
const DEP_KIND: DepKind;
3233

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

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

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

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

src/librustc/ty/query/plumbing.rs

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ where
191191
};
192192

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

196196
(job.latch(id), _query_blocked_prof_timer)
197197
}
@@ -206,7 +206,7 @@ where
206206
lock.jobs = id;
207207
let id = QueryShardJobId(NonZeroU32::new(id).unwrap());
208208

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

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

@@ -540,7 +540,7 @@ impl<'tcx> TyCtxt<'tcx> {
540540

541541
let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| {
542542
self.start_query(job.id, diagnostics, |tcx| {
543-
tcx.dep_graph.with_anon_task(Q::dep_kind(), || Q::compute(tcx, key))
543+
tcx.dep_graph.with_anon_task(Q::DEP_KIND, || Q::compute(tcx, key))
544544
})
545545
});
546546

@@ -916,7 +916,7 @@ macro_rules! define_queries_inner {
916916
job: job.id,
917917
shard: u16::try_from(shard_id).unwrap(),
918918
kind:
919-
<queries::$name<'tcx> as QueryAccessors<'tcx>>::dep_kind(),
919+
<queries::$name<'tcx> as QueryAccessors<'tcx>>::DEP_KIND,
920920
};
921921
let info = QueryInfo {
922922
span: job.span,
@@ -1023,6 +1023,7 @@ macro_rules! define_queries_inner {
10231023
impl<$tcx> QueryAccessors<$tcx> for queries::$name<$tcx> {
10241024
const ANON: bool = is_anon!([$($modifiers)*]);
10251025
const EVAL_ALWAYS: bool = is_eval_always!([$($modifiers)*]);
1026+
const DEP_KIND: dep_graph::DepKind = dep_graph::DepKind::$node;
10261027

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

@@ -1042,11 +1043,6 @@ macro_rules! define_queries_inner {
10421043
DepConstructor::$node(tcx, *key)
10431044
}
10441045

1045-
#[inline(always)]
1046-
fn dep_kind() -> dep_graph::DepKind {
1047-
dep_graph::DepKind::$node
1048-
}
1049-
10501046
#[inline]
10511047
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value {
10521048
__query_compute::$name(tcx, key)

0 commit comments

Comments
 (0)