rust/compiler/rustc_query_system/src/dep_graph/mod.rs

86 lines
2.4 KiB
Rust
Raw Normal View History

pub mod debug;
mod dep_node;
mod graph;
mod prev;
mod query;
mod serialized;
2020-03-18 10:25:22 +01:00
pub use dep_node::{DepNode, DepNodeParams, WorkProductId};
pub use graph::{hash_result, DepGraph, DepNodeColor, DepNodeIndex, TaskDeps, WorkProduct};
pub use prev::PreviousDepGraph;
pub use query::DepGraphQuery;
pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
use rustc_data_structures::profiling::SelfProfilerRef;
use rustc_data_structures::sync::Lock;
use rustc_session::Session;
2020-03-18 10:25:22 +01:00
use std::fmt;
use std::hash::Hash;
pub trait DepContext: Copy {
2020-03-18 10:25:22 +01:00
type DepKind: self::DepKind;
2020-03-27 08:33:37 +01:00
type StableHashingContext;
2020-03-18 10:25:22 +01:00
/// Create a hashing context for hashing new results.
fn create_stable_hashing_context(&self) -> Self::StableHashingContext;
/// Access the DepGraph.
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
fn register_reused_dep_node(&self, dep_node: &DepNode<Self::DepKind>);
2020-03-18 10:25:22 +01:00
/// Access the profiler.
fn profiler(&self) -> &SelfProfilerRef;
/// Access the compiler session.
fn sess(&self) -> &Session;
2020-03-18 10:25:22 +01:00
}
2020-10-18 21:01:36 +02:00
pub trait HasDepContext: Copy {
type DepKind: self::DepKind;
type StableHashingContext;
type DepContext: self::DepContext<
DepKind = Self::DepKind,
StableHashingContext = Self::StableHashingContext,
>;
fn dep_context(&self) -> &Self::DepContext;
}
impl<T: DepContext> HasDepContext for T {
type DepKind = T::DepKind;
type StableHashingContext = T::StableHashingContext;
type DepContext = Self;
fn dep_context(&self) -> &Self::DepContext {
self
}
}
2020-03-18 10:25:22 +01:00
/// Describe the different families of dependency nodes.
pub trait DepKind: Copy + fmt::Debug + Eq + Hash {
2020-03-18 21:02:02 +01:00
const NULL: Self;
2020-03-18 10:25:22 +01:00
/// Return whether this kind always require evaluation.
fn is_eval_always(&self) -> bool;
/// Return whether this kind requires additional parameters to be executed.
fn has_params(&self) -> bool;
/// Implementation of `std::fmt::Debug` for `DepNode`.
fn debug_node(node: &DepNode<Self>, f: &mut fmt::Formatter<'_>) -> fmt::Result;
/// Execute the operation with provided dependencies.
fn with_deps<OP, R>(deps: Option<&Lock<TaskDeps<Self>>>, op: OP) -> R
where
OP: FnOnce() -> R;
/// Access dependencies from current implicit context.
fn read_deps<OP>(op: OP)
2020-03-18 10:25:22 +01:00
where
OP: for<'a> FnOnce(Option<&'a Lock<TaskDeps<Self>>>);
2020-03-18 21:02:02 +01:00
fn can_reconstruct_query_key(&self) -> bool;
2020-03-18 10:25:22 +01:00
}