Skip to content

Commit

Permalink
Make QueryAccessor::compute an associated const.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Mar 7, 2020
1 parent cae3639 commit 4b11ee8
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 6 deletions.
4 changes: 2 additions & 2 deletions src/librustc/ty/query/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<Fingerprint>;
Expand All @@ -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,
Expand Down
5 changes: 1 addition & 4 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<'_>,
Expand Down

0 comments on commit 4b11ee8

Please sign in to comment.