about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTyson Nottingham <tgnottingham@gmail.com>2021-01-06 12:41:36 -0800
committerTyson Nottingham <tgnottingham@gmail.com>2021-01-12 11:22:58 -0800
commit0962e5eba91cc873b2546d1b727dcddd33fde6a8 (patch)
treecddd5ed12914e9bcdecebb0be60d77032fe59197
parent62139ffad4a77d45b9651b04b440c89c5b9c1b5c (diff)
downloadrust-0962e5eba91cc873b2546d1b727dcddd33fde6a8.tar.gz
rust-0962e5eba91cc873b2546d1b727dcddd33fde6a8.zip
Return to defining crate_hash similarly to other query providers
-rw-r--r--compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs22
1 files changed, 5 insertions, 17 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
index 979e70b9e31..85507b8f843 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
@@ -44,7 +44,10 @@ macro_rules! provide {
                 let ($def_id, $other) = def_id_arg.into_args();
                 assert!(!$def_id.is_local());
 
-                if $tcx.dep_graph.is_fully_enabled() {
+                // External query providers call `crate_hash` in order to register a dependency
+                // on the crate metadata. The exception is `crate_hash` itself, which obviously
+                // doesn't need to do this (and can't, as it would cause a query cycle).
+                if stringify!($name) != "crate_hash" && $tcx.dep_graph.is_fully_enabled() {
                     $tcx.ensure().crate_hash($def_id.krate);
                 }
 
@@ -53,24 +56,8 @@ macro_rules! provide {
                 $compute
             })*
 
-            // The other external query providers call `crate_hash` in order to register a
-            // dependency on the crate metadata. The `crate_hash` implementation differs in
-            // that it doesn't need to do this (and can't, as it would cause a query cycle).
-            fn crate_hash<'tcx>(
-                tcx: TyCtxt<'tcx>,
-                def_id_arg: ty::query::query_keys::crate_hash<'tcx>,
-            ) -> ty::query::query_values::crate_hash<'tcx> {
-                let _prof_timer = tcx.prof.generic_activity("metadata_decode_entry_crate_hash");
-
-                let (def_id, _) = def_id_arg.into_args();
-                assert!(!def_id.is_local());
-
-                CStore::from_tcx(tcx).get_crate_data(def_id.krate).root.hash
-            }
-
             *providers = Providers {
                 $($name,)*
-                crate_hash,
                 ..*providers
             };
         }
@@ -206,6 +193,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
         })
     }
     crate_disambiguator => { cdata.root.disambiguator }
+    crate_hash => { cdata.root.hash }
     crate_host_hash => { cdata.host_hash }
     original_crate_name => { cdata.root.name }