Skip to content

Commit 8e7cbc2

Browse files
committed
Prevent potential bug resulting from changing crate_hash query name
1 parent 0962e5e commit 8e7cbc2

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

Diff for: compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,8 @@ macro_rules! provide {
4747
// External query providers call `crate_hash` in order to register a dependency
4848
// on the crate metadata. The exception is `crate_hash` itself, which obviously
4949
// doesn't need to do this (and can't, as it would cause a query cycle).
50-
if stringify!($name) != "crate_hash" && $tcx.dep_graph.is_fully_enabled() {
50+
use rustc_middle::dep_graph::DepKind;
51+
if DepKind::$name != DepKind::crate_hash && $tcx.dep_graph.is_fully_enabled() {
5152
$tcx.ensure().crate_hash($def_id.krate);
5253
}
5354

Diff for: compiler/rustc_middle/src/query/mod.rs

+2
Original file line numberDiff line numberDiff line change
@@ -1220,6 +1220,8 @@ rustc_queries! {
12201220
eval_always
12211221
desc { "looking up the disambiguator a crate" }
12221222
}
1223+
// The macro which defines `rustc_metadata::provide_extern` depends on this query's name.
1224+
// Changing the name should cause a compiler error, but in case that changes, be aware.
12231225
query crate_hash(_: CrateNum) -> Svh {
12241226
eval_always
12251227
desc { "looking up the hash a crate" }

0 commit comments

Comments
 (0)