Skip to content

Commit

Permalink
Make encode_query_results more generic.
Browse files Browse the repository at this point in the history
  • Loading branch information
cjgillot committed Feb 19, 2021
1 parent 24dbb61 commit 23f9d10
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 7 deletions.
14 changes: 8 additions & 6 deletions compiler/rustc_middle/src/ty/query/on_disk_cache.rs
Expand Up @@ -3,7 +3,6 @@ use crate::mir::interpret::{AllocDecodingSession, AllocDecodingState};
use crate::mir::{self, interpret};
use crate::ty::codec::{RefDecodable, TyDecoder, TyEncoder};
use crate::ty::context::TyCtxt;
use crate::ty::query::QueryCtxt;
use crate::ty::{self, Ty};
use rustc_data_structures::fingerprint::{Fingerprint, FingerprintDecoder, FingerprintEncoder};
use rustc_data_structures::fx::{FxHashMap, FxHashSet, FxIndexSet};
Expand All @@ -15,6 +14,8 @@ use rustc_hir::def_id::{CrateNum, DefId, DefIndex, LocalDefId, LOCAL_CRATE};
use rustc_hir::definitions::DefPathHash;
use rustc_hir::definitions::Definitions;
use rustc_index::vec::{Idx, IndexVec};
use rustc_query_system::dep_graph::DepContext;
use rustc_query_system::query::QueryContext;
use rustc_serialize::{
opaque::{self, FileEncodeResult, FileEncoder},
Decodable, Decoder, Encodable, Encoder,
Expand Down Expand Up @@ -1215,18 +1216,19 @@ impl<'a> Decodable<opaque::Decoder<'a>> for IntEncodedWithFixedSize {
}
}

pub fn encode_query_results<'a, 'tcx, Q>(
tcx: QueryCtxt<'tcx>,
pub fn encode_query_results<'a, 'tcx, CTX, Q>(
tcx: CTX,
encoder: &mut CacheEncoder<'a, 'tcx, FileEncoder>,
query_result_index: &mut EncodedQueryResultIndex,
) -> FileEncodeResult
where
Q: super::QueryDescription<QueryCtxt<'tcx>> + super::QueryAccessors<QueryCtxt<'tcx>>,
CTX: QueryContext + 'tcx,
Q: super::QueryDescription<CTX> + super::QueryAccessors<CTX>,
Q::Value: Encodable<CacheEncoder<'a, 'tcx, FileEncoder>>,
{
let _timer = tcx
.sess
.prof
.dep_context()
.profiler()
.extra_verbose_generic_activity("encode_query_results_for", std::any::type_name::<Q>());

assert!(Q::query_state(tcx).all_inactive());
Expand Down
2 changes: 1 addition & 1 deletion compiler/rustc_middle/src/ty/query/plumbing.rs
Expand Up @@ -251,7 +251,7 @@ impl<'tcx> QueryCtxt<'tcx> {
macro_rules! encode_queries {
($($query:ident,)*) => {
$(
on_disk_cache::encode_query_results::<ty::query::queries::$query<'_>>(
on_disk_cache::encode_query_results::<_, ty::query::queries::$query<'_>>(
self,
encoder,
query_result_index
Expand Down

0 comments on commit 23f9d10

Please sign in to comment.