1
Fork 0

Query the fingerprint style during key reconstruction

Keys can be reconstructed from fingerprints that are not DefPathHash, but then
we cannot extract a DefId from them.
This commit is contained in:
Mark Rousskov 2021-10-02 12:06:42 -04:00
parent 0eabf25b90
commit 6f78eed1c7
6 changed files with 74 additions and 48 deletions

View file

@ -50,6 +50,27 @@ impl<T: DepContext> HasDepContext for T {
}
}
/// Describes the contents of the fingerprint generated by a given query.
#[derive(PartialEq, Eq, Copy, Clone)]
pub enum FingerprintStyle {
/// The fingerprint is actually a DefPathHash.
DefPathHash,
/// Query key was `()` or equivalent, so fingerprint is just zero.
Unit,
/// Some opaque hash.
Opaque,
}
impl FingerprintStyle {
#[inline]
pub fn reconstructible(self) -> bool {
match self {
FingerprintStyle::DefPathHash | FingerprintStyle::Unit => true,
FingerprintStyle::Opaque => false,
}
}
}
/// Describe the different families of dependency nodes.
pub trait DepKind: Copy + fmt::Debug + Eq + Hash + Send + Encodable<FileEncoder> + 'static {
const NULL: Self;
@ -73,5 +94,5 @@ pub trait DepKind: Copy + fmt::Debug + Eq + Hash + Send + Encodable<FileEncoder>
where
OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps<Self>>>);
fn can_reconstruct_query_key(&self) -> bool;
fn fingerprint_style(&self) -> FingerprintStyle;
}