Skip to content

Commit

Permalink
Make QueryDescription::reify an associated const.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Mar 7, 2020
1 parent 4b11ee8 commit 3e259b9
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
22 changes: 10 additions & 12 deletions src/librustc/ty/query/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -99,18 +99,16 @@ pub(crate) trait QueryDescription<'tcx>: QueryAccessors<'tcx> {
bug!("QueryDescription::load_from_disk() called for an unsupported query.")
}

fn reify() -> QueryVtable<'tcx, Self::Key, Self::Value> {
QueryVtable {
anon: Self::ANON,
dep_kind: Self::DEP_KIND,
eval_always: Self::EVAL_ALWAYS,
name: Self::NAME,
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,
}
}
const VTABLE: QueryVtable<'tcx, Self::Key, Self::Value> = QueryVtable {
anon: Self::ANON,
dep_kind: Self::DEP_KIND,
eval_always: Self::EVAL_ALWAYS,
name: Self::NAME,
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,
};
}

impl<'tcx, M: QueryAccessors<'tcx, Key = DefId>> QueryDescription<'tcx> for M {
Expand Down
2 changes: 1 addition & 1 deletion src/librustc/ty/query/on_disk_cache.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ impl<'sess> OnDiskCache<'sess> {
encode_query_results(
tcx,
ty::query::queries::$query::query_state(tcx),
&ty::query::queries::$query::reify(),
&ty::query::queries::$query::VTABLE,
enc,
qri
)?;
Expand Down
10 changes: 5 additions & 5 deletions src/librustc/ty/query/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -545,11 +545,11 @@ impl<'tcx> TyCtxt<'tcx> {
// expensive for some `DepKind`s.
if !self.dep_graph.is_fully_enabled() {
let null_dep_node = DepNode::new_no_params(crate::dep_graph::DepKind::Null);
return self.force_query_with_job(key, job, null_dep_node, &Q::reify()).0;
return self.force_query_with_job(key, job, null_dep_node, &Q::VTABLE).0;
}

if Q::ANON {
let (result, dep_node_index) = self.try_execute_anon_query(key, job.id, &Q::reify());
let (result, dep_node_index) = self.try_execute_anon_query(key, job.id, &Q::VTABLE);

job.complete(&result, dep_node_index);

Expand All @@ -559,15 +559,15 @@ impl<'tcx> TyCtxt<'tcx> {
let dep_node = Q::to_dep_node(self, &key);

if !Q::EVAL_ALWAYS {
let loaded = self.start_incremental_query(key.clone(), &dep_node, job.id, &Q::reify());
let loaded = self.start_incremental_query(key.clone(), &dep_node, job.id, &Q::VTABLE);

if let Some((result, dep_node_index)) = loaded {
job.complete(&result, dep_node_index);
return result;
}
}

let (result, dep_node_index) = self.force_query_with_job(key, job, dep_node, &Q::reify());
let (result, dep_node_index) = self.force_query_with_job(key, job, dep_node, &Q::VTABLE);
self.dep_graph.read_index(dep_node_index);
result
}
Expand Down Expand Up @@ -832,7 +832,7 @@ impl<'tcx> TyCtxt<'tcx> {
#[cfg(parallel_compiler)]
TryGetJob::JobCompleted(_) => return,
};
self.force_query_with_job(key, job, dep_node, &Q::reify());
self.force_query_with_job(key, job, dep_node, &Q::VTABLE);
},
);
}
Expand Down

0 comments on commit 3e259b9

Please sign in to comment.