about summary refs log tree commit diff
diff options
context:
space:
mode:
authorTyson Nottingham <tgnottingham@gmail.com>2021-01-11 13:31:43 -0800
committerTyson Nottingham <tgnottingham@gmail.com>2021-01-12 11:22:58 -0800
commit8e7cbc28a65df0e979b6052db7f4f8d26fecd9d9 (patch)
treee0234d48477656f5725b78e28293299fd4f389a8
parent0962e5eba91cc873b2546d1b727dcddd33fde6a8 (diff)
downloadrust-8e7cbc28a65df0e979b6052db7f4f8d26fecd9d9.tar.gz
rust-8e7cbc28a65df0e979b6052db7f4f8d26fecd9d9.zip
Prevent potential bug resulting from changing crate_hash query name
-rw-r--r--compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs3
-rw-r--r--compiler/rustc_middle/src/query/mod.rs2
2 files changed, 4 insertions, 1 deletions
diff --git a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
index 85507b8f843..f50c84adb26 100644
--- a/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
+++ b/compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
@@ -47,7 +47,8 @@ macro_rules! provide {
                 // 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() {
+                use rustc_middle::dep_graph::DepKind;
+                if DepKind::$name != DepKind::crate_hash && $tcx.dep_graph.is_fully_enabled() {
                     $tcx.ensure().crate_hash($def_id.krate);
                 }
 
diff --git a/compiler/rustc_middle/src/query/mod.rs b/compiler/rustc_middle/src/query/mod.rs
index 1e836d0a842..0818af1e810 100644
--- a/compiler/rustc_middle/src/query/mod.rs
+++ b/compiler/rustc_middle/src/query/mod.rs
@@ -1220,6 +1220,8 @@ rustc_queries! {
             eval_always
             desc { "looking up the disambiguator a crate" }
         }
+        // The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
+        // Changing the name should cause a compiler error, but in case that changes, be aware.
         query crate_hash(_: CrateNum) -> Svh {
             eval_always
             desc { "looking up the hash a crate" }