Skip to content

Commit 4b11ee8

Browse files
committed
Make QueryAccessor::compute an associated const.
1 parent cae3639 commit 4b11ee8

File tree

2 files changed

+3
-6
lines changed

2 files changed

+3
-6
lines changed

src/librustc/ty/query/config.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,7 @@ pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> {
7979
fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode;
8080

8181
// Don't use this method to compute query results, instead use the methods on TyCtxt
82-
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value;
82+
const COMPUTE_FN: fn(TyCtxt<'tcx>, Self::Key) -> Self::Value;
8383

8484
fn hash_result(hcx: &mut StableHashingContext<'_>, result: &Self::Value)
8585
-> Option<Fingerprint>;
@@ -105,7 +105,7 @@ pub(crate) trait QueryDescription<'tcx>: QueryAccessors<'tcx> {
105105
dep_kind: Self::DEP_KIND,
106106
eval_always: Self::EVAL_ALWAYS,
107107
name: Self::NAME,
108-
compute: Self::compute,
108+
compute: Self::COMPUTE_FN,
109109
hash_result: Self::hash_result,
110110
cache_on_disk: Self::cache_on_disk,
111111
try_load_from_disk: Self::try_load_from_disk,

src/librustc/ty/query/plumbing.rs

+1-4
Original file line numberDiff line numberDiff line change
@@ -1037,10 +1037,7 @@ macro_rules! define_queries_inner {
10371037
DepConstructor::$node(tcx, *key)
10381038
}
10391039

1040-
#[inline]
1041-
fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value {
1042-
__query_compute::$name(tcx, key)
1043-
}
1040+
const COMPUTE_FN: fn(TyCtxt<'tcx>, Self::Key) -> Self::Value = __query_compute::$name;
10441041

10451042
fn hash_result(
10461043
_hcx: &mut StableHashingContext<'_>,

0 commit comments

Comments
 (0)