]> git.proxmox.com Git - rustc.git/blame - compiler/rustc_query_system/src/dep_graph/mod.rs
New upstream version 1.51.0+dfsg1
[rustc.git] / compiler / rustc_query_system / src / dep_graph / mod.rs
CommitLineData
ba9703b0
XL
1pub mod debug;
2mod dep_node;
3mod graph;
4mod prev;
5mod query;
6mod serialized;
7
8pub use dep_node::{DepNode, DepNodeParams, WorkProductId};
ba9703b0
XL
9pub use graph::{hash_result, DepGraph, DepNodeColor, DepNodeIndex, TaskDeps, WorkProduct};
10pub use prev::PreviousDepGraph;
11pub use query::DepGraphQuery;
12pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
13
14use rustc_data_structures::profiling::SelfProfilerRef;
15use rustc_data_structures::sync::Lock;
16use rustc_data_structures::thin_vec::ThinVec;
17use rustc_errors::Diagnostic;
18
19use std::fmt;
20use std::hash::Hash;
21
22pub 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
fc512014
XL
35 fn register_reused_dep_node(&self, dep_node: &DepNode<Self::DepKind>);
36
ba9703b0
XL
37 /// Return whether the current session is tainted by errors.
38 fn has_errors_or_delayed_span_bugs(&self) -> bool;
39
40 /// Return the diagnostic handler.
41 fn diagnostic(&self) -> &rustc_errors::Handler;
42
43 /// Load data from the on-disk cache.
44 fn try_load_from_on_disk_cache(&self, dep_node: &DepNode<Self::DepKind>);
45
46 /// Load diagnostics associated to the node in the previous session.
47 fn load_diagnostics(&self, prev_dep_node_index: SerializedDepNodeIndex) -> Vec<Diagnostic>;
48
49 /// Register diagnostics for the given node, for use in next session.
50 fn store_diagnostics(&self, dep_node_index: DepNodeIndex, diagnostics: ThinVec<Diagnostic>);
51
52 /// Register diagnostics for the given node, for use in next session.
53 fn store_diagnostics_for_anon_node(
54 &self,
55 dep_node_index: DepNodeIndex,
56 diagnostics: ThinVec<Diagnostic>,
57 );
58
59 /// Access the profiler.
60 fn profiler(&self) -> &SelfProfilerRef;
61}
62
63/// Describe the different families of dependency nodes.
5869c6ff 64pub trait DepKind: Copy + fmt::Debug + Eq + Hash {
ba9703b0
XL
65 const NULL: Self;
66
67 /// Return whether this kind always require evaluation.
68 fn is_eval_always(&self) -> bool;
69
70 /// Return whether this kind requires additional parameters to be executed.
71 fn has_params(&self) -> bool;
72
73 /// Implementation of `std::fmt::Debug` for `DepNode`.
74 fn debug_node(node: &DepNode<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result;
75
76 /// Execute the operation with provided dependencies.
77 fn with_deps<OP, R>(deps: Option<&Lock<TaskDeps<Self>>>, op: OP) -> R
78 where
79 OP: FnOnce() -> R;
80
81 /// Access dependencies from current implicit context.
f9f354fc 82 fn read_deps<OP>(op: OP)
ba9703b0 83 where
f9f354fc 84 OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps<Self>>>);
ba9703b0
XL
85
86 fn can_reconstruct_query_key(&self) -> bool;
87}