Move the fingerprint_style special case into DepKindVTable creation
This commit is contained in:
parent
a1db344c08
commit
b4bf57b7aa
3 changed files with 14 additions and 10 deletions
|
|
@ -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,
|
||||
|
|
@ -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 {
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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)]
|
||||
|
|
@ -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.
|
||||
|
|
@ -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.
|
||||
Opaque,
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue