Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 6 additions & 2 deletions compiler/rustc_query_impl/src/plumbing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ use rustc_middle::ty::codec::TyEncoder;
use rustc_middle::ty::print::with_reduced_queries;
use rustc_middle::ty::tls::{self, ImplicitCtxt};
use rustc_middle::ty::{self, TyCtxt};
use rustc_query_system::dep_graph::{DepNodeParams, HasDepContext};
use rustc_query_system::dep_graph::{DepNodeParams, FingerprintStyle, HasDepContext};
use rustc_query_system::ich::StableHashingContext;
use rustc_query_system::query::{
QueryCache, QueryContext, QueryDispatcher, QueryJobId, QueryMap, QuerySideEffect,
Expand Down Expand Up @@ -519,7 +519,11 @@ pub(crate) fn make_dep_kind_vtable_for_query<'tcx, Q>(
where
Q: QueryDispatcherUnerased<'tcx>,
{
let fingerprint_style = <Q::Dispatcher as QueryDispatcher>::Key::fingerprint_style();
let fingerprint_style = if is_anon {
FingerprintStyle::Opaque
} else {
<Q::Dispatcher as QueryDispatcher>::Key::fingerprint_style()
};

if is_anon || !fingerprint_style.reconstructible() {
return DepKindVTable {
Expand Down
5 changes: 3 additions & 2 deletions compiler/rustc_query_system/src/dep_graph/dep_node.rs
Original file line number Diff line number Diff line change
Expand Up @@ -237,8 +237,9 @@ pub struct DepKindVTable<Tcx: DepContext> {
/// cached within one compiler invocation.
pub is_eval_always: bool,

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

/// The red/green evaluation system will try to mark a specific DepNode in the
Expand Down
11 changes: 5 additions & 6 deletions compiler/rustc_query_system/src/dep_graph/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,7 @@ pub trait DepContext: Copy {

#[inline(always)]
fn fingerprint_style(self, kind: DepKind) -> FingerprintStyle {
let vtable = self.dep_kind_vtable(kind);
if vtable.is_anon {
return FingerprintStyle::Opaque;
}
vtable.fingerprint_style
self.dep_kind_vtable(kind).fingerprint_style
}

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

/// Describes the contents of the fingerprint generated by a given query.
///
/// This is mainly for determining whether and how we can reconstruct a key
/// from the fingerprint.
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
pub enum FingerprintStyle {
/// The fingerprint is actually a DefPathHash.
Expand All @@ -156,7 +155,7 @@ pub enum FingerprintStyle {
HirId,
/// Query key was `()` or equivalent, so fingerprint is just zero.
Unit,
/// Some opaque hash.
/// The fingerprint is an opaque hash, and a key cannot be reconstructed from it.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that in the anon case the fingerprint isn't even a hash of the key.

Opaque,
}

Expand Down
Loading