8 pub use dep_node::{DepNode, DepNodeParams, WorkProductId};
9 pub use graph::{hash_result, DepGraph, DepNodeColor, DepNodeIndex, TaskDeps, WorkProduct};
10 pub use prev::PreviousDepGraph;
11 pub use query::DepGraphQuery;
12 pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
14 use rustc_data_structures::profiling::SelfProfilerRef;
15 use rustc_data_structures::sync::Lock;
16 use rustc_data_structures::thin_vec::ThinVec;
17 use rustc_errors::Diagnostic;
22 pub trait DepContext: Copy {
23 type DepKind: self::DepKind;
24 type StableHashingContext;
26 /// Create a hashing context for hashing new results.
27 fn create_stable_hashing_context(&self) -> Self::StableHashingContext;
29 fn debug_dep_tasks(&self) -> bool;
30 fn debug_dep_node(&self) -> bool;
32 /// Try to force a dep node to execute and see if it's green.
33 fn try_force_from_dep_node(&self, dep_node: &DepNode<Self::DepKind>) -> bool;
35 fn register_reused_dep_node(&self, dep_node: &DepNode<Self::DepKind>);
37 /// Return whether the current session is tainted by errors.
38 fn has_errors_or_delayed_span_bugs(&self) -> bool;
40 /// Return the diagnostic handler.
41 fn diagnostic(&self) -> &rustc_errors::Handler;
43 /// Load data from the on-disk cache.
44 fn try_load_from_on_disk_cache(&self, dep_node: &DepNode<Self::DepKind>);
46 /// Load diagnostics associated to the node in the previous session.
47 fn load_diagnostics(&self, prev_dep_node_index: SerializedDepNodeIndex) -> Vec<Diagnostic>;
49 /// Register diagnostics for the given node, for use in next session.
50 fn store_diagnostics(&self, dep_node_index: DepNodeIndex, diagnostics: ThinVec<Diagnostic>);
52 /// Register diagnostics for the given node, for use in next session.
53 fn store_diagnostics_for_anon_node(
55 dep_node_index: DepNodeIndex,
56 diagnostics: ThinVec<Diagnostic>,
59 /// Access the profiler.
60 fn profiler(&self) -> &SelfProfilerRef;
63 /// Describe the different families of dependency nodes.
64 pub trait DepKind: Copy + fmt::Debug + Eq + Ord + Hash {
67 /// Return whether this kind always require evaluation.
68 fn is_eval_always(&self) -> bool;
70 /// Return whether this kind requires additional parameters to be executed.
71 fn has_params(&self) -> bool;
73 /// Implementation of `std::fmt::Debug` for `DepNode`.
74 fn debug_node(node: &DepNode<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result;
76 /// Execute the operation with provided dependencies.
77 fn with_deps<OP, R>(deps: Option<&Lock<TaskDeps<Self>>>, op: OP) -> R
81 /// Access dependencies from current implicit context.
82 fn read_deps<OP>(op: OP)
84 OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps<Self>>>);
86 fn can_reconstruct_query_key(&self) -> bool;