8 pub use dep_node
::{DepNode, DepNodeParams, WorkProductId}
;
9 pub use graph
::WorkProductFileKind
;
10 pub use graph
::{hash_result, DepGraph, DepNodeColor, DepNodeIndex, TaskDeps, WorkProduct}
;
11 pub use prev
::PreviousDepGraph
;
12 pub use query
::DepGraphQuery
;
13 pub use serialized
::{SerializedDepGraph, SerializedDepNodeIndex}
;
15 use rustc_data_structures
::profiling
::SelfProfilerRef
;
16 use rustc_data_structures
::sync
::Lock
;
17 use rustc_data_structures
::thin_vec
::ThinVec
;
18 use rustc_errors
::Diagnostic
;
23 pub trait DepContext
: Copy
{
24 type DepKind
: self::DepKind
;
25 type StableHashingContext
;
27 /// Create a hashing context for hashing new results.
28 fn create_stable_hashing_context(&self) -> Self::StableHashingContext
;
30 fn debug_dep_tasks(&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 /// Return whether the current session is tainted by errors.
36 fn has_errors_or_delayed_span_bugs(&self) -> bool
;
38 /// Return the diagnostic handler.
39 fn diagnostic(&self) -> &rustc_errors
::Handler
;
41 /// Load data from the on-disk cache.
42 fn try_load_from_on_disk_cache(&self, dep_node
: &DepNode
<Self::DepKind
>);
44 /// Load diagnostics associated to the node in the previous session.
45 fn load_diagnostics(&self, prev_dep_node_index
: SerializedDepNodeIndex
) -> Vec
<Diagnostic
>;
47 /// Register diagnostics for the given node, for use in next session.
48 fn store_diagnostics(&self, dep_node_index
: DepNodeIndex
, diagnostics
: ThinVec
<Diagnostic
>);
50 /// Register diagnostics for the given node, for use in next session.
51 fn store_diagnostics_for_anon_node(
53 dep_node_index
: DepNodeIndex
,
54 diagnostics
: ThinVec
<Diagnostic
>,
57 /// Access the profiler.
58 fn profiler(&self) -> &SelfProfilerRef
;
61 /// Describe the different families of dependency nodes.
62 pub trait DepKind
: Copy
+ fmt
::Debug
+ Eq
+ Ord
+ Hash
{
65 /// Return whether this kind always require evaluation.
66 fn is_eval_always(&self) -> bool
;
68 /// Return whether this kind requires additional parameters to be executed.
69 fn has_params(&self) -> bool
;
71 /// Implementation of `std::fmt::Debug` for `DepNode`.
72 fn debug_node(node
: &DepNode
<Self>, f
: &mut fmt
::Formatter
<'_
>) -> fmt
::Result
;
74 /// Execute the operation with provided dependencies.
75 fn with_deps
<OP
, R
>(deps
: Option
<&Lock
<TaskDeps
<Self>>>, op
: OP
) -> R
79 /// Access dependencies from current implicit context.
80 fn read_deps
<OP
>(op
: OP
) -> ()
82 OP
: for<'a
> FnOnce(Option
<&'a Lock
<TaskDeps
<Self>>>) -> ();
84 fn can_reconstruct_query_key(&self) -> bool
;