Skip to content

Commit b4bf57b

Browse files
committed
Move the fingerprint_style special case into DepKindVTable creation
1 parent a1db344 commit b4bf57b

File tree

3 files changed

+14
-10
lines changed

3 files changed

+14
-10
lines changed

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,7 @@ use rustc_middle::ty::codec::TyEncoder;
2424
use rustc_middle::ty::print::with_reduced_queries;
2525
use rustc_middle::ty::tls::{self, ImplicitCtxt};
2626
use rustc_middle::ty::{self, TyCtxt};
27-
use rustc_query_system::dep_graph::{DepNodeParams, HasDepContext};
27+
use rustc_query_system::dep_graph::{DepNodeParams, FingerprintStyle, HasDepContext};
2828
use rustc_query_system::ich::StableHashingContext;
2929
use rustc_query_system::query::{
3030
QueryCache, QueryContext, QueryDispatcher, QueryJobId, QueryMap, QuerySideEffect,
@@ -519,7 +519,11 @@ pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q>(
519519
where
520520
Q: QueryDispatcherUnerased<'tcx>,
521521
{
522-
let fingerprint_style = <Q::Dispatcher as QueryDispatcher>::Key::fingerprint_style();
522+
let fingerprint_style = if is_anon {
523+
FingerprintStyle::Opaque
524+
} else {
525+
<Q::Dispatcher as QueryDispatcher>::Key::fingerprint_style()
526+
};
523527

524528
if is_anon || !fingerprint_style.reconstructible() {
525529
return DepKindVTable {

compiler/rustc_query_system/src/dep_graph/dep_node.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -237,8 +237,9 @@ pub struct DepKindVTable<Tcx: DepContext> {
237237
/// cached within one compiler invocation.
238238
pub is_eval_always: bool,
239239

240-
/// Whether the query key can be recovered from the hashed fingerprint.
241-
/// See [DepNodeParams] trait for the behaviour of each key type.
240+
/// Indicates whether and how the query key can be recovered from its hashed fingerprint.
241+
///
242+
/// The [`DepNodeParams`] trait determines the fingerprint style for each key type.
242243
pub fingerprint_style: FingerprintStyle,
243244

244245
/// The red/green evaluation system will try to mark a specific DepNode in the

compiler/rustc_query_system/src/dep_graph/mod.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -39,11 +39,7 @@ pub trait DepContext: Copy {
3939

4040
#[inline(always)]
4141
fn fingerprint_style(self, kind: DepKind) -> FingerprintStyle {
42-
let vtable = self.dep_kind_vtable(kind);
43-
if vtable.is_anon {
44-
return FingerprintStyle::Opaque;
45-
}
46-
vtable.fingerprint_style
42+
self.dep_kind_vtable(kind).fingerprint_style
4743
}
4844

4945
#[inline(always)]
@@ -148,6 +144,9 @@ impl<T: HasDepContext, Q: Copy> HasDepContext for (T, Q) {
148144
}
149145

150146
/// Describes the contents of the fingerprint generated by a given query.
147+
///
148+
/// This is mainly for determining whether and how we can reconstruct a key
149+
/// from the fingerprint.
151150
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
152151
pub enum FingerprintStyle {
153152
/// The fingerprint is actually a DefPathHash.
@@ -156,7 +155,7 @@ pub enum FingerprintStyle {
156155
HirId,
157156
/// Query key was `()` or equivalent, so fingerprint is just zero.
158157
Unit,
159-
/// Some opaque hash.
158+
/// The fingerprint is an opaque hash, and a key cannot be reconstructed from it.
160159
Opaque,
161160
}
162161

0 commit comments

Comments
 (0)