about summary refs log tree commit diff
path: root/compiler/rustc_macros/src
diff options
context:
space:
mode:
authorJoshua Nelson <jnelson@cloudflare.com>2022-09-01 21:54:06 -0500
committerJoshua Nelson <jnelson@cloudflare.com>2022-09-09 20:16:48 -0500
commit112419c9f0b7f369df149e002429c85fc05f5e86 (patch)
tree37c8f98e9cfe44865ffe9b9036d822bdd4d7ea55 /compiler/rustc_macros/src
parent8da754ef00488ffdb1259f104fd6084327b3bd45 (diff)
downloadrust-112419c9f0b7f369df149e002429c85fc05f5e86.tar.gz
rust-112419c9f0b7f369df149e002429c85fc05f5e86.zip
Remove dead `load_cached` code in rustc_query
Diffstat (limited to 'compiler/rustc_macros/src')
-rw-r--r--compiler/rustc_macros/src/query.rs35
1 files changed, 2 insertions, 33 deletions
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<Pat>, 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<Ident>,
 
@@ -120,7 +117,6 @@ struct QueryModifiers {
 }
 
 fn parse_query_modifiers(input: ParseStream<'_>) -> Result<QueryModifiers> {
-    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<QueryModifiers> {
             };
             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::<Token![,]>()?;
-            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<QueryModifiers> {
         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<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
-                    = Some(|#tcx, #id| { #block });
-            }
-        } else {
-            // Use the default code to load the query from disk
-            quote! {
-                const TRY_LOAD_FROM_DISK: Option<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
-                    = 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<fn(QueryCtxt<'tcx>, SerializedDepNodeIndex) -> Option<Self::Value>>
+                = 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 {