@@ -63,6 +63,7 @@ use rustc_data_structures::fingerprint::Fingerprint;
6363use rustc_hir::def_id::{CrateNum, DefId, LocalDefId, CRATE_DEF_INDEX};
6464use rustc_hir::definitions::DefPathHash;
6565use rustc_hir::HirId;
66+ use rustc_query_system::dep_graph::FingerprintStyle;
6667use rustc_span::symbol::Symbol;
6768use std::hash::Hash;
6869
@@ -89,9 +90,9 @@ pub struct DepKindStruct {
8990
9091 /// Whether the query key can be recovered from the hashed fingerprint.
9192 /// See [DepNodeParams] trait for the behaviour of each key type.
92- // FIXME: Make this a simple boolean once DepNodeParams::can_reconstruct_query_key
93+ // FIXME: Make this a simple boolean once DepNodeParams::fingerprint_style
9394 // can be made a specialized associated const.
94- can_reconstruct_query_key : fn() -> bool ,
95+ fingerprint_style : fn() -> FingerprintStyle ,
9596}
9697
9798impl std::ops::Deref for DepKind {
@@ -103,14 +104,14 @@ impl std::ops::Deref for DepKind {
103104
104105impl DepKind {
105106 #[inline(always)]
106- pub fn can_reconstruct_query_key (&self) -> bool {
107+ pub fn fingerprint_style (&self) -> FingerprintStyle {
107108 // Only fetch the DepKindStruct once.
108109 let data: &DepKindStruct = &**self;
109110 if data.is_anon {
110- return false ;
111+ return FingerprintStyle::Opaque ;
111112 }
112113
113- (data.can_reconstruct_query_key )()
114+ (data.fingerprint_style )()
114115 }
115116}
116117
@@ -151,38 +152,39 @@ macro_rules! contains_eval_always_attr {
151152pub mod dep_kind {
152153 use super::*;
153154 use crate::ty::query::query_keys;
155+ use rustc_query_system::dep_graph::FingerprintStyle;
154156
155157 // We use this for most things when incr. comp. is turned off.
156158 pub const Null: DepKindStruct = DepKindStruct {
157159 has_params: false,
158160 is_anon: false,
159161 is_eval_always: false,
160162
161- can_reconstruct_query_key : || true ,
163+ fingerprint_style : || FingerprintStyle::Unit ,
162164 };
163165
164166 pub const TraitSelect: DepKindStruct = DepKindStruct {
165167 has_params: false,
166168 is_anon: true,
167169 is_eval_always: false,
168170
169- can_reconstruct_query_key : || true ,
171+ fingerprint_style : || FingerprintStyle::Unit ,
170172 };
171173
172174 pub const CompileCodegenUnit: DepKindStruct = DepKindStruct {
173175 has_params: true,
174176 is_anon: false,
175177 is_eval_always: false,
176178
177- can_reconstruct_query_key : || false ,
179+ fingerprint_style : || FingerprintStyle::Opaque ,
178180 };
179181
180182 pub const CompileMonoItem: DepKindStruct = DepKindStruct {
181183 has_params: true,
182184 is_anon: false,
183185 is_eval_always: false,
184186
185- can_reconstruct_query_key : || false ,
187+ fingerprint_style : || FingerprintStyle::Opaque ,
186188 };
187189
188190 macro_rules! define_query_dep_kinds {
@@ -196,16 +198,16 @@ pub mod dep_kind {
196198 const is_eval_always: bool = contains_eval_always_attr!($($attrs)*);
197199
198200 #[inline(always)]
199- fn can_reconstruct_query_key () -> bool {
201+ fn fingerprint_style () -> rustc_query_system::dep_graph::FingerprintStyle {
200202 <query_keys::$variant<'_> as DepNodeParams<TyCtxt<'_>>>
201- ::can_reconstruct_query_key ()
203+ ::fingerprint_style ()
202204 }
203205
204206 DepKindStruct {
205207 has_params,
206208 is_anon,
207209 is_eval_always,
208- can_reconstruct_query_key ,
210+ fingerprint_style ,
209211 }
210212 };)*
211213 );
@@ -320,7 +322,7 @@ impl DepNodeExt for DepNode {
320322 /// method will assert that the given DepKind actually requires a
321323 /// single DefId/DefPathHash parameter.
322324 fn from_def_path_hash(def_path_hash: DefPathHash, kind: DepKind) -> DepNode {
323- debug_assert!(kind.can_reconstruct_query_key () && kind.has_params );
325+ debug_assert!(kind.fingerprint_style () == FingerprintStyle::DefPathHash );
324326 DepNode { kind, hash: def_path_hash.0.into() }
325327 }
326328
@@ -335,7 +337,7 @@ impl DepNodeExt for DepNode {
335337 /// refers to something from the previous compilation session that
336338 /// has been removed.
337339 fn extract_def_id(&self, tcx: TyCtxt<'tcx>) -> Option<DefId> {
338- if self.kind.can_reconstruct_query_key() {
340+ if self.kind.fingerprint_style() == FingerprintStyle::DefPathHash {
339341 Some(
340342 tcx.on_disk_cache
341343 .as_ref()?
@@ -350,14 +352,16 @@ impl DepNodeExt for DepNode {
350352 fn from_label_string(label: &str, def_path_hash: DefPathHash) -> Result<DepNode, ()> {
351353 let kind = dep_kind_from_label_string(label)?;
352354
353- if !kind.can_reconstruct_query_key() {
354- return Err(());
355- }
356-
357- if kind.has_params {
358- Ok(DepNode::from_def_path_hash(def_path_hash, kind))
359- } else {
360- Ok(DepNode::new_no_params(kind))
355+ match kind.fingerprint_style() {
356+ FingerprintStyle::Opaque => Err(()),
357+ FingerprintStyle::Unit => {
358+ if !kind.has_params {
359+ Ok(DepNode::new_no_params(kind))
360+ } else {
361+ Err(())
362+ }
363+ }
364+ FingerprintStyle::DefPathHash => Ok(DepNode::from_def_path_hash(def_path_hash, kind)),
361365 }
362366 }
363367
@@ -369,8 +373,8 @@ impl DepNodeExt for DepNode {
369373
370374impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for () {
371375 #[inline(always)]
372- fn can_reconstruct_query_key () -> bool {
373- true
376+ fn fingerprint_style () -> FingerprintStyle {
377+ FingerprintStyle::Unit
374378 }
375379
376380 fn to_fingerprint(&self, _: TyCtxt<'tcx>) -> Fingerprint {
@@ -384,8 +388,8 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for () {
384388
385389impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for DefId {
386390 #[inline(always)]
387- fn can_reconstruct_query_key () -> bool {
388- true
391+ fn fingerprint_style () -> FingerprintStyle {
392+ FingerprintStyle::DefPathHash
389393 }
390394
391395 fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
@@ -403,8 +407,8 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for DefId {
403407
404408impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalDefId {
405409 #[inline(always)]
406- fn can_reconstruct_query_key () -> bool {
407- true
410+ fn fingerprint_style () -> FingerprintStyle {
411+ FingerprintStyle::DefPathHash
408412 }
409413
410414 fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
@@ -422,8 +426,8 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for LocalDefId {
422426
423427impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for CrateNum {
424428 #[inline(always)]
425- fn can_reconstruct_query_key () -> bool {
426- true
429+ fn fingerprint_style () -> FingerprintStyle {
430+ FingerprintStyle::DefPathHash
427431 }
428432
429433 fn to_fingerprint(&self, tcx: TyCtxt<'tcx>) -> Fingerprint {
@@ -442,8 +446,8 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for CrateNum {
442446
443447impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId) {
444448 #[inline(always)]
445- fn can_reconstruct_query_key () -> bool {
446- false
449+ fn fingerprint_style () -> FingerprintStyle {
450+ FingerprintStyle::Opaque
447451 }
448452
449453 // We actually would not need to specialize the implementation of this
@@ -467,8 +471,8 @@ impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for (DefId, DefId) {
467471
468472impl<'tcx> DepNodeParams<TyCtxt<'tcx>> for HirId {
469473 #[inline(always)]
470- fn can_reconstruct_query_key () -> bool {
471- false
474+ fn fingerprint_style () -> FingerprintStyle {
475+ FingerprintStyle::Opaque
472476 }
473477
474478 // We actually would not need to specialize the implementation of this
0 commit comments