]> git.lizzy.rs Git - rust.git/blobdiff - compiler/rustc_query_system/src/dep_graph/mod.rs
Use a dedicated DepKind for the forever-red node.
[rust.git] / compiler / rustc_query_system / src / dep_graph / mod.rs
index 5907ae309ca377abb9c5e81966f8999fa6e18a94..342d95ca490ea276a5ecd2dfb3b2bc6aa3b44f1f 100644 (file)
@@ -23,7 +23,7 @@ pub trait DepContext: Copy {
     type DepKind: self::DepKind;
 
     /// Create a hashing context for hashing new results.
-    fn create_stable_hashing_context(&self) -> StableHashingContext<'_>;
+    fn with_stable_hashing_context<R>(&self, f: impl FnOnce(StableHashingContext<'_>) -> R) -> R;
 
     /// Access the DepGraph.
     fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
@@ -85,8 +85,12 @@ pub fn reconstructible(self) -> bool {
 
 /// Describe the different families of dependency nodes.
 pub trait DepKind: Copy + fmt::Debug + Eq + Hash + Send + Encodable<FileEncoder> + 'static {
+    /// DepKind to use when incr. comp. is turned off.
     const NULL: Self;
 
+    /// DepKind to use to create the initial forever-red node.
+    const RED: Self;
+
     /// Implementation of `std::fmt::Debug` for `DepNode`.
     fn debug_node(node: &DepNode<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result;