Skip to content

Commit

Permalink
Return to defining crate_hash similarly to other query providers
Browse files Browse the repository at this point in the history
  • Loading branch information
tgnottingham committed Jan 12, 2021
1 parent 62139ff commit 0962e5e
Showing 1 changed file with 5 additions and 17 deletions.
22 changes: 5 additions & 17 deletions compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs
Expand Up @@ -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);
}

Expand All @@ -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
};
}
Expand Down Expand Up @@ -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 }

Expand Down

0 comments on commit 0962e5e

Please sign in to comment.