diff --git a/compiler/rustc_macros/src/query.rs b/compiler/rustc_macros/src/query.rs index 77fb997dc48..50bd95834b1 100644 --- a/compiler/rustc_macros/src/query.rs +++ b/compiler/rustc_macros/src/query.rs @@ -91,9 +91,6 @@ struct QueryModifiers { /// Cache the query to disk if the `Block` returns true. cache: Option<(Option, Block)>, - /// Custom code to load the query from disk. - load_cached: Option<(Ident, Ident, Block)>, - /// A cycle error for this query aborting the compilation with a fatal error. fatal_cycle: Option, @@ -120,7 +117,6 @@ struct QueryModifiers { } fn parse_query_modifiers(input: ParseStream<'_>) -> Result { - let mut load_cached = None; let mut arena_cache = None; let mut cache = None; let mut desc = None; @@ -173,16 +169,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result { }; let block = input.parse()?; try_insert!(cache = (args, block)); - } else if modifier == "load_cached" { - // Parse a load_cached modifier like: - // `load_cached(tcx, id) { tcx.on_disk_cache.try_load_query_result(tcx, id) }` - let args; - parenthesized!(args in input); - let tcx = args.parse()?; - args.parse::()?; - let id = args.parse()?; - let block = input.parse()?; - try_insert!(load_cached = (tcx, id, block)); } else if modifier == "arena_cache" { try_insert!(arena_cache = modifier); } else if modifier == "fatal_cycle" { @@ -209,7 +195,6 @@ fn parse_query_modifiers(input: ParseStream<'_>) -> Result { return Err(input.error("no description provided")); }; Ok(QueryModifiers { - load_cached, arena_cache, cache, desc, @@ -259,20 +244,6 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea // Find out if we should cache the query on disk let cache = if let Some((args, expr)) = modifiers.cache.as_ref() { - let try_load_from_disk = if let Some((tcx, id, block)) = modifiers.load_cached.as_ref() { - // Use custom code to load the query from disk - quote! { - const TRY_LOAD_FROM_DISK: Option, SerializedDepNodeIndex) -> Option> - = Some(|#tcx, #id| { #block }); - } - } else { - // Use the default code to load the query from disk - quote! { - const TRY_LOAD_FROM_DISK: Option, SerializedDepNodeIndex) -> Option> - = Some(|tcx, id| tcx.on_disk_cache().as_ref()?.try_load_query_result(*tcx, id)); - } - }; - let tcx = args.as_ref().map(|t| quote! { #t }).unwrap_or_else(|| quote! { _ }); // expr is a `Block`, meaning that `{ #expr }` gets expanded // to `{ { stmts... } }`, which triggers the `unused_braces` lint. @@ -283,12 +254,10 @@ fn add_query_description_impl(query: &Query, impls: &mut proc_macro2::TokenStrea #expr } - #try_load_from_disk + const TRY_LOAD_FROM_DISK: Option, SerializedDepNodeIndex) -> Option> + = Some(|tcx, id| tcx.on_disk_cache().as_ref()?.try_load_query_result(*tcx, id)); } } else { - if modifiers.load_cached.is_some() { - panic!("load_cached modifier on query `{}` without a cache modifier", name); - } quote! { #[inline] fn cache_on_disk(_: TyCtxt<'tcx>, _: &Self::Key) -> bool {