From 4b11ee82bb31d4d058f7c39f303d8c8e9f7b55d4 Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 6 Mar 2020 23:49:28 +0100 Subject: [PATCH] Make QueryAccessor::compute an associated const. --- src/librustc/ty/query/config.rs | 4 ++-- src/librustc/ty/query/plumbing.rs | 5 +---- 2 files changed, 3 insertions(+), 6 deletions(-) diff --git a/src/librustc/ty/query/config.rs b/src/librustc/ty/query/config.rs index 1661512f76472..a0cea63ed38b4 100644 --- a/src/librustc/ty/query/config.rs +++ b/src/librustc/ty/query/config.rs @@ -79,7 +79,7 @@ pub(crate) trait QueryAccessors<'tcx>: QueryConfig<'tcx> { fn to_dep_node(tcx: TyCtxt<'tcx>, key: &Self::Key) -> DepNode; // 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; + const COMPUTE_FN: fn(TyCtxt<'tcx>, Self::Key) -> Self::Value; fn hash_result(hcx: &mut StableHashingContext<'_>, result: &Self::Value) -> Option; @@ -105,7 +105,7 @@ pub(crate) trait QueryDescription<'tcx>: QueryAccessors<'tcx> { dep_kind: Self::DEP_KIND, eval_always: Self::EVAL_ALWAYS, name: Self::NAME, - compute: Self::compute, + compute: Self::COMPUTE_FN, hash_result: Self::hash_result, cache_on_disk: Self::cache_on_disk, try_load_from_disk: Self::try_load_from_disk, diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 9e5937b85b3bb..f36cebed00c78 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -1037,10 +1037,7 @@ macro_rules! define_queries_inner { DepConstructor::$node(tcx, *key) } - #[inline] - fn compute(tcx: TyCtxt<'tcx>, key: Self::Key) -> Self::Value { - __query_compute::$name(tcx, key) - } + const COMPUTE_FN: fn(TyCtxt<'tcx>, Self::Key) -> Self::Value = __query_compute::$name; fn hash_result( _hcx: &mut StableHashingContext<'_>,