Skip to content

Commit 0a4f347

Browse files
incr.comp.: Cache generics_of query.
1 parent a5d7aae commit 0a4f347

File tree

3 files changed

+19
-2
lines changed

3 files changed

+19
-2
lines changed

src/librustc/ty/maps/config.rs

+17-2
Original file line numberDiff line numberDiff line change
@@ -617,8 +617,8 @@ impl<'tcx> QueryDescription<'tcx> for queries::optimized_mir<'tcx> {
617617
}
618618

619619
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
620-
id: SerializedDepNodeIndex)
621-
-> Option<Self::Value> {
620+
id: SerializedDepNodeIndex)
621+
-> Option<Self::Value> {
622622
let mir: Option<::mir::Mir<'tcx>> = tcx.on_disk_query_result_cache
623623
.try_load_query_result(tcx, id);
624624
mir.map(|x| tcx.alloc_mir(x))
@@ -637,6 +637,21 @@ impl<'tcx> QueryDescription<'tcx> for queries::target_features_whitelist<'tcx> {
637637
}
638638
}
639639

640+
impl<'tcx> QueryDescription<'tcx> for queries::generics_of<'tcx> {
641+
#[inline]
642+
fn cache_on_disk(def_id: Self::Key) -> bool {
643+
def_id.is_local()
644+
}
645+
646+
fn try_load_from_disk<'a>(tcx: TyCtxt<'a, 'tcx, 'tcx>,
647+
id: SerializedDepNodeIndex)
648+
-> Option<Self::Value> {
649+
let generics: Option<ty::Generics> = tcx.on_disk_query_result_cache
650+
.try_load_query_result(tcx, id);
651+
generics.map(|x| tcx.alloc_generics(x))
652+
}
653+
}
654+
640655
macro_rules! impl_disk_cacheable_query(
641656
($query_name:ident, |$key:tt| $cond:expr) => {
642657
impl<'tcx> QueryDescription<'tcx> for queries::$query_name<'tcx> {

src/librustc/ty/maps/on_disk_cache.rs

+1
Original file line numberDiff line numberDiff line change
@@ -205,6 +205,7 @@ impl<'sess> OnDiskCache<'sess> {
205205
let qri = &mut query_result_index;
206206

207207
encode_query_results::<type_of, _>(tcx, enc, qri)?;
208+
encode_query_results::<generics_of, _>(tcx, enc, qri)?;
208209
encode_query_results::<predicates_of, _>(tcx, enc, qri)?;
209210
encode_query_results::<used_trait_imports, _>(tcx, enc, qri)?;
210211
encode_query_results::<typeck_tables_of, _>(tcx, enc, qri)?;

src/librustc/ty/maps/plumbing.rs

+1
Original file line numberDiff line numberDiff line change
@@ -983,6 +983,7 @@ impl_load_from_cache!(
983983
ContainsExternIndicator => contains_extern_indicator,
984984
CheckMatch => check_match,
985985
TypeOfItem => type_of,
986+
GenericsOfItem => generics_of,
986987
PredicatesOfItem => predicates_of,
987988
UsedTraitImports => used_trait_imports,
988989
);

0 commit comments

Comments
 (0)