]>
Commit | Line | Data |
---|---|---|
ba9703b0 XL |
1 | pub mod debug; |
2 | mod dep_node; | |
3 | mod graph; | |
4 | mod prev; | |
5 | mod query; | |
6 | mod serialized; | |
7 | ||
8 | pub use dep_node::{DepNode, DepNodeParams, WorkProductId}; | |
ba9703b0 XL |
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}; | |
13 | ||
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; | |
18 | ||
19 | use std::fmt; | |
20 | use std::hash::Hash; | |
21 | ||
22 | pub trait DepContext: Copy { | |
23 | type DepKind: self::DepKind; | |
24 | type StableHashingContext; | |
25 | ||
26 | /// Create a hashing context for hashing new results. | |
27 | fn create_stable_hashing_context(&self) -> Self::StableHashingContext; | |
28 | ||
29 | fn debug_dep_tasks(&self) -> bool; | |
f9f354fc | 30 | fn debug_dep_node(&self) -> bool; |
ba9703b0 XL |
31 | |
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; | |
34 | ||
35 | /// Return whether the current session is tainted by errors. | |
36 | fn has_errors_or_delayed_span_bugs(&self) -> bool; | |
37 | ||
38 | /// Return the diagnostic handler. | |
39 | fn diagnostic(&self) -> &rustc_errors::Handler; | |
40 | ||
41 | /// Load data from the on-disk cache. | |
42 | fn try_load_from_on_disk_cache(&self, dep_node: &DepNode<Self::DepKind>); | |
43 | ||
44 | /// Load diagnostics associated to the node in the previous session. | |
45 | fn load_diagnostics(&self, prev_dep_node_index: SerializedDepNodeIndex) -> Vec<Diagnostic>; | |
46 | ||
47 | /// Register diagnostics for the given node, for use in next session. | |
48 | fn store_diagnostics(&self, dep_node_index: DepNodeIndex, diagnostics: ThinVec<Diagnostic>); | |
49 | ||
50 | /// Register diagnostics for the given node, for use in next session. | |
51 | fn store_diagnostics_for_anon_node( | |
52 | &self, | |
53 | dep_node_index: DepNodeIndex, | |
54 | diagnostics: ThinVec<Diagnostic>, | |
55 | ); | |
56 | ||
57 | /// Access the profiler. | |
58 | fn profiler(&self) -> &SelfProfilerRef; | |
59 | } | |
60 | ||
61 | /// Describe the different families of dependency nodes. | |
62 | pub trait DepKind: Copy + fmt::Debug + Eq + Ord + Hash { | |
63 | const NULL: Self; | |
64 | ||
65 | /// Return whether this kind always require evaluation. | |
66 | fn is_eval_always(&self) -> bool; | |
67 | ||
68 | /// Return whether this kind requires additional parameters to be executed. | |
69 | fn has_params(&self) -> bool; | |
70 | ||
71 | /// Implementation of `std::fmt::Debug` for `DepNode`. | |
72 | fn debug_node(node: &DepNode<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result; | |
73 | ||
74 | /// Execute the operation with provided dependencies. | |
75 | fn with_deps<OP, R>(deps: Option<&Lock<TaskDeps<Self>>>, op: OP) -> R | |
76 | where | |
77 | OP: FnOnce() -> R; | |
78 | ||
79 | /// Access dependencies from current implicit context. | |
f9f354fc | 80 | fn read_deps<OP>(op: OP) |
ba9703b0 | 81 | where |
f9f354fc | 82 | OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps<Self>>>); |
ba9703b0 XL |
83 | |
84 | fn can_reconstruct_query_key(&self) -> bool; | |
85 | } |