@@ -44,7 +44,10 @@ macro_rules! provide {
44
44
let ( $def_id, $other) = def_id_arg. into_args( ) ;
45
45
assert!( !$def_id. is_local( ) ) ;
46
46
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( ) {
48
51
$tcx. ensure( ) . crate_hash( $def_id. krate) ;
49
52
}
50
53
@@ -53,24 +56,8 @@ macro_rules! provide {
53
56
$compute
54
57
} ) *
55
58
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
-
71
59
* providers = Providers {
72
60
$( $name, ) *
73
- crate_hash,
74
61
..* providers
75
62
} ;
76
63
}
@@ -206,6 +193,7 @@ provide! { <'tcx> tcx, def_id, other, cdata,
206
193
} )
207
194
}
208
195
crate_disambiguator => { cdata. root. disambiguator }
196
+ crate_hash => { cdata. root. hash }
209
197
crate_host_hash => { cdata. host_hash }
210
198
original_crate_name => { cdata. root. name }
211
199
0 commit comments