From 9273782d559a342beb2443018f2f8fc873f53b79 Mon Sep 17 00:00:00 2001 From: Joshua Nelson Date: Mon, 5 Sep 2022 06:43:11 -0500 Subject: 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. --- compiler/rustc_macros/src/query.rs | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) (limited to 'compiler/rustc_macros/src') diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs index 55d23ba1c67..742ae964f5c 100644 --- a/compiler/rustc_macros/src/query.rs +++ b/compiler/rustc_macros/src/query.rs @@ -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 { #expr } - - const TRY_LOAD_FROM_DISK: Option, SerializedDepNodeIndex) -> Option> - = Some(crate::plumbing::try_load_from_disk::); } } else { 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 { false } - - const TRY_LOAD_FROM_DISK: Option, SerializedDepNodeIndex) -> Option> = None; } }; @@ -333,6 +328,10 @@ pub fn rustc_queries(input: TokenStream) -> TokenStream { remap_env_constness, ); + if modifiers.cache.is_some() { + attributes.push(quote! { (cache) }); + } + // This uses the span of the query definition for the commas, // which can be important if we later encounter any ambiguity // errors with any of the numerous macro_rules! macros that -- cgit 1.4.1-3-g733a5