mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-25 08:13:41 +00:00
Move TRY_LOAD_FROM_DISK
out of rustc_queries
to rustc_query_impl
We want to refer to `crate::plumbing::try_load_from_disk` in the const, but hard-coding it in rustc_queries, where we don't yet know the crate this macro will be called in, seems kind of hacky. Do it in query_impl instead.
This commit is contained in:
parent
7208bdee33
commit
9273782d55
@ -253,9 +253,6 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
|
|||||||
fn cache_on_disk(#tcx: TyCtxt<'tcx>, #key: &Self::Key) -> bool {
|
fn cache_on_disk(#tcx: TyCtxt<'tcx>, #key: &Self::Key) -> bool {
|
||||||
#expr
|
#expr
|
||||||
}
|
}
|
||||||
|
|
||||||
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
|
|
||||||
= Some(crate::plumbing::try_load_from_disk::<Self::Value>);
|
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
quote! {
|
quote! {
|
||||||
@ -263,8 +260,6 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea
|
|||||||
fn cache_on_disk(_: TyCtxt<'tcx>, _: &Self::Key) -> bool {
|
fn cache_on_disk(_: TyCtxt<'tcx>, _: &Self::Key) -> bool {
|
||||||
false
|
false
|
||||||
}
|
}
|
||||||
|
|
||||||
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>> = None;
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
@ -333,6 +328,10 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream {
|
|||||||
remap_env_constness,
|
remap_env_constness,
|
||||||
);
|
);
|
||||||
|
|
||||||
|
if modifiers.cache.is_some() {
|
||||||
|
attributes.push(quote! { (cache) });
|
||||||
|
}
|
||||||
|
|
||||||
// This uses the span of the query definition for the commas,
|
// This uses the span of the query definition for the commas,
|
||||||
// which can be important if we later encounter any ambiguity
|
// which can be important if we later encounter any ambiguity
|
||||||
// errors with any of the numerous macro_rules! macros that
|
// errors with any of the numerous macro_rules! macros that
|
||||||
|
@ -412,6 +412,9 @@ macro_rules! define_queries {
|
|||||||
impl<'tcx> QueryDescription<QueryCtxt<'tcx>> for queries::$name<'tcx> {
|
impl<'tcx> QueryDescription<QueryCtxt<'tcx>> for queries::$name<'tcx> {
|
||||||
rustc_query_description! { $name }
|
rustc_query_description! { $name }
|
||||||
|
|
||||||
|
const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
|
||||||
|
= should_ever_cache_on_disk!([$($modifiers)*]);
|
||||||
|
|
||||||
type Cache = query_storage::$name<'tcx>;
|
type Cache = query_storage::$name<'tcx>;
|
||||||
|
|
||||||
#[inline(always)]
|
#[inline(always)]
|
||||||
|
Loading…
Reference in New Issue
Block a user