Skip to content

Commit

Permalink
Prevent potential bug resulting from changing crate_hash query name
Browse files Browse the repository at this point in the history
  • Loading branch information
tgnottingham committed Jan 12, 2021
1 parent 0962e5e commit 8e7cbc2
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 1 deletion.
3 changes: 2 additions & 1 deletion compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
2 changes: 2 additions & 0 deletions compiler/rustc_middle/src/query/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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" }
Expand Down

0 comments on commit 8e7cbc2

Please sign in to comment.