Wrap TyCtxt inside a QueryCtxt for queries.

This commit is contained in:
Camille GILLOT 2020-04-08 17:03:34 +02:00
parent dab9b89221
commit 2db2776589
9 changed files with 82 additions and 49 deletions

View file

@ -354,9 +354,10 @@ fn add_query_description_impl(
quote! {
#[inline]
fn try_load_from_disk(
#tcx: TyCtxt<'tcx>,
#id: SerializedDepNodeIndex
tcx: QueryCtxt<'tcx>,
id: SerializedDepNodeIndex
) -> Option<Self::Value> {
let (#tcx, #id) = (*tcx, id);
#block
}
}
@ -365,10 +366,10 @@ fn add_query_description_impl(
quote! {
#[inline]
fn try_load_from_disk(
tcx: TyCtxt<'tcx>,
tcx: QueryCtxt<'tcx>,
id: SerializedDepNodeIndex
) -> Option<Self::Value> {
tcx.on_disk_cache.as_ref()?.try_load_query_result(tcx, id)
tcx.on_disk_cache.as_ref()?.try_load_query_result(*tcx, id)
}
}
};
@ -393,10 +394,11 @@ fn add_query_description_impl(
#[inline]
#[allow(unused_variables, unused_braces)]
fn cache_on_disk(
#tcx: TyCtxt<'tcx>,
#key: &Self::Key,
#value: Option<&Self::Value>
tcx: QueryCtxt<'tcx>,
key: &Self::Key,
value: Option<&Self::Value>
) -> bool {
let (#tcx, #key, #value) = (*tcx, key, value);
#expr
}
@ -414,16 +416,14 @@ fn add_query_description_impl(
let desc = quote! {
#[allow(unused_variables)]
fn describe(
#tcx: TyCtxt<'tcx>,
#key: #arg,
) -> String {
::rustc_middle::ty::print::with_no_trimmed_paths(|| format!(#desc))
fn describe(tcx: QueryCtxt<'tcx>, key: #arg) -> String {
let (#tcx, #key) = (*tcx, key);
::rustc_middle::ty::print::with_no_trimmed_paths(|| format!(#desc).into())
}
};
impls.extend(quote! {
impl<'tcx> QueryDescription<TyCtxt<'tcx>> for queries::#name<'tcx> {
impl<'tcx> QueryDescription<QueryCtxt<'tcx>> for queries::#name<'tcx> {
#desc
#cache
}