Skip to content

Commit 0962e5e

Browse files
committed
Return to defining crate_hash similarly to other query providers
1 parent 62139ff commit 0962e5e

File tree

1 file changed

+5
-17
lines changed

1 file changed

+5
-17
lines changed

compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs

+5-17
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,10 @@ macro_rules! provide {
4444
let ($def_id, $other) = def_id_arg.into_args();
4545
assert!(!$def_id.is_local());
4646

47-
if $tcx.dep_graph.is_fully_enabled() {
47+
// External query providers call `crate_hash` in order to register a dependency
48+
// on the crate metadata. The exception is `crate_hash` itself, which obviously
49+
// 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() {
4851
$tcx.ensure().crate_hash($def_id.krate);
4952
}
5053

@@ -53,24 +56,8 @@ macro_rules! provide {
5356
$compute
5457
})*
5558

56-
// The other external query providers call `crate_hash` in order to register a
57-
// dependency on the crate metadata. The `crate_hash` implementation differs in
58-
// that it doesn't need to do this (and can't, as it would cause a query cycle).
59-
fn crate_hash<'tcx>(
60-
tcx: TyCtxt<'tcx>,
61-
def_id_arg: ty::query::query_keys::crate_hash<'tcx>,
62-
) -> ty::query::query_values::crate_hash<'tcx> {
63-
let _prof_timer = tcx.prof.generic_activity("metadata_decode_entry_crate_hash");
64-
65-
let (def_id, _) = def_id_arg.into_args();
66-
assert!(!def_id.is_local());
67-
68-
CStore::from_tcx(tcx).get_crate_data(def_id.krate).root.hash
69-
}
70-
7159
*providers = Providers {
7260
$($name,)*
73-
crate_hash,
7461
..*providers
7562
};
7663
}
@@ -206,6 +193,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
206193
})
207194
}
208195
crate_disambiguator => { cdata.root.disambiguator }
196+
crate_hash => { cdata.root.hash }
209197
crate_host_hash => { cdata.host_hash }
210198
original_crate_name => { cdata.root.name }
211199

0 commit comments

Comments
 (0)