pub use query::DepGraphQuery;
pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
+use crate::ich::StableHashingContext;
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::sync::Lock;
use rustc_serialize::{opaque::FileEncoder, Encodable};
pub trait DepContext: Copy {
type DepKind: self::DepKind;
- type StableHashingContext;
/// Create a hashing context for hashing new results.
- fn create_stable_hashing_context(&self) -> Self::StableHashingContext;
+ fn create_stable_hashing_context(&self) -> StableHashingContext<'_>;
/// Access the DepGraph.
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
- fn register_reused_dep_node(&self, dep_node: &DepNode<Self::DepKind>);
-
/// Access the profiler.
fn profiler(&self) -> &SelfProfilerRef;
pub trait HasDepContext: Copy {
type DepKind: self::DepKind;
- type StableHashingContext;
- type DepContext: self::DepContext<
- DepKind = Self::DepKind,
- StableHashingContext = Self::StableHashingContext,
- >;
+ type DepContext: self::DepContext<DepKind = Self::DepKind>;
fn dep_context(&self) -> &Self::DepContext;
}
impl<T: DepContext> HasDepContext for T {
type DepKind = T::DepKind;
- type StableHashingContext = T::StableHashingContext;
type DepContext = Self;
fn dep_context(&self) -> &Self::DepContext {
}
}
+/// 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;
where
OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps<Self>>>);
- fn can_reconstruct_query_key(&self) -> bool;
+ fn fingerprint_style(&self) -> FingerprintStyle;
}