use rustc_hir::def_id::DefId;
mod dep_node;
-mod safe;
pub(crate) use rustc_query_system::dep_graph::DepNodeParams;
pub use rustc_query_system::dep_graph::{
};
pub use dep_node::{label_strs, DepConstructor, DepKind, DepNode, DepNodeExt};
-pub use safe::AssertDepGraphSafe;
-pub use safe::DepGraphSafe;
pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepKind>;
pub type TaskDeps = rustc_query_system::dep_graph::TaskDeps<DepKind>;
self.sess().opts.debugging_opts.dep_tasks
}
}
-
-impl rustc_query_system::HashStableContextProvider<StableHashingContext<'tcx>> for TyCtxt<'tcx> {
- fn get_stable_hashing_context(&self) -> StableHashingContext<'tcx> {
- self.create_stable_hashing_context()
- }
-}
-
-impl rustc_query_system::HashStableContextProvider<StableHashingContext<'a>>
- for StableHashingContext<'a>
-{
- fn get_stable_hashing_context(&self) -> Self {
- self.clone()
- }
-}
+++ /dev/null
-//! The `DepGraphSafe` trait
-
-use crate::ty::TyCtxt;
-
-pub use rustc_query_system::dep_graph::{AssertDepGraphSafe, DepGraphSafe};
-
-/// The type context itself can be used to access all kinds of tracked
-/// state, but those accesses should always generate read events.
-impl<'tcx> DepGraphSafe for TyCtxt<'tcx> {}
}
}
-impl<'a> crate::dep_graph::DepGraphSafe for StableHashingContext<'a> {}
-
impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
fn hash_stable(&self, _: &mut StableHashingContext<'a>, _: &mut StableHasher) {
panic!("Node IDs should not appear in incremental state");
use crate::value::Value;
use rustc::bug;
-use rustc::dep_graph::DepGraphSafe;
use rustc::mir::mono::CodegenUnit;
use rustc::ty::layout::{
HasParamEnv, LayoutError, LayoutOf, PointeeInfo, Size, TyLayout, VariantIdx,
local_gen_sym_counter: Cell<usize>,
}
-impl<'ll, 'tcx> DepGraphSafe for CodegenCx<'ll, 'tcx> {}
-
pub fn get_reloc_model(sess: &Session) -> llvm::RelocMode {
let reloc_model_arg = match sess.opts.cg.relocation_model {
Some(ref s) => &s[..],
use super::debug::EdgeFilter;
use super::prev::PreviousDepGraph;
use super::query::DepGraphQuery;
-use super::safe::DepGraphSafe;
use super::serialized::{SerializedDepGraph, SerializedDepNodeIndex};
use super::{DepContext, DepKind, DepNode, WorkProductId};
-use crate::{HashStableContext, HashStableContextProvider};
+use crate::HashStableContext;
#[derive(Clone)]
pub struct DepGraph<K: DepKind> {
/// `arg` parameter.
///
/// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/incremental-compilation.html
- pub fn with_task<H, C, A, R>(
+ pub fn with_task<Ctxt: DepContext<DepKind = K>, A, R>(
&self,
key: DepNode<K>,
- cx: C,
+ cx: Ctxt,
arg: A,
- task: fn(C, A) -> R,
- hash_result: impl FnOnce(&mut H, &R) -> Option<Fingerprint>,
- ) -> (R, DepNodeIndex)
- where
- C: DepGraphSafe + HashStableContextProvider<H>,
- H: HashStableContext,
- {
+ task: fn(Ctxt, A) -> R,
+ hash_result: impl FnOnce(&mut Ctxt::StableHashingContext, &R) -> Option<Fingerprint>,
+ ) -> (R, DepNodeIndex) {
self.with_task_impl(
key,
cx,
)
}
- fn with_task_impl<H, C, A, R>(
+ fn with_task_impl<Ctxt: DepContext<DepKind = K>, A, R>(
&self,
key: DepNode<K>,
- cx: C,
+ cx: Ctxt,
arg: A,
no_tcx: bool,
- task: fn(C, A) -> R,
+ task: fn(Ctxt, A) -> R,
create_task: fn(DepNode<K>) -> Option<TaskDeps<K>>,
finish_task_and_alloc_depnode: fn(
&CurrentDepGraph<K>,
Fingerprint,
Option<TaskDeps<K>>,
) -> DepNodeIndex,
- hash_result: impl FnOnce(&mut H, &R) -> Option<Fingerprint>,
- ) -> (R, DepNodeIndex)
- where
- C: DepGraphSafe + HashStableContextProvider<H>,
- H: HashStableContext,
- {
+ hash_result: impl FnOnce(&mut Ctxt::StableHashingContext, &R) -> Option<Fingerprint>,
+ ) -> (R, DepNodeIndex) {
if let Some(ref data) = self.data {
let task_deps = create_task(key).map(Lock::new);
// anyway so that
// - we make sure that the infrastructure works and
// - we can get an idea of the runtime cost.
- let mut hcx = cx.get_stable_hashing_context();
+ let mut hcx = cx.create_stable_hashing_context();
let result = if no_tcx {
task(cx, arg)
/// Executes something within an "eval-always" task which is a task
/// that runs whenever anything changes.
- pub fn with_eval_always_task<H, C, A, R>(
+ pub fn with_eval_always_task<Ctxt: DepContext<DepKind = K>, A, R>(
&self,
key: DepNode<K>,
- cx: C,
+ cx: Ctxt,
arg: A,
- task: fn(C, A) -> R,
- hash_result: impl FnOnce(&mut H, &R) -> Option<Fingerprint>,
- ) -> (R, DepNodeIndex)
- where
- C: DepGraphSafe + HashStableContextProvider<H>,
- H: HashStableContext,
- {
+ task: fn(Ctxt, A) -> R,
+ hash_result: impl FnOnce(&mut Ctxt::StableHashingContext, &R) -> Option<Fingerprint>,
+ ) -> (R, DepNodeIndex) {
self.with_task_impl(
key,
cx,
mod graph;
mod prev;
mod query;
-mod safe;
mod serialized;
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 safe::AssertDepGraphSafe;
-pub use safe::DepGraphSafe;
pub use serialized::{SerializedDepGraph, SerializedDepNodeIndex};
use rustc_data_structures::profiling::SelfProfilerRef;
use std::fmt;
use std::hash::Hash;
-pub trait DepContext: Copy + DepGraphSafe {
+pub trait DepContext: Copy {
type DepKind: self::DepKind;
type StableHashingContext: crate::HashStableContext;
+++ /dev/null
-//! The `DepGraphSafe` trait
-
-use rustc_ast::ast::NodeId;
-use rustc_hir::def_id::DefId;
-use rustc_hir::BodyId;
-
-/// The `DepGraphSafe` trait is used to specify what kinds of values
-/// are safe to "leak" into a task. The idea is that this should be
-/// only be implemented for things like the tcx as well as various id
-/// types, which will create reads in the dep-graph whenever the trait
-/// loads anything that might depend on the input program.
-pub trait DepGraphSafe {}
-
-/// A `BodyId` on its own doesn't give access to any particular state.
-/// You must fetch the state from the various maps or generate
-/// on-demand queries, all of which create reads.
-impl DepGraphSafe for BodyId {}
-
-/// A `NodeId` on its own doesn't give access to any particular state.
-/// You must fetch the state from the various maps or generate
-/// on-demand queries, all of which create reads.
-impl DepGraphSafe for NodeId {}
-
-/// A `DefId` on its own doesn't give access to any particular state.
-/// You must fetch the state from the various maps or generate
-/// on-demand queries, all of which create reads.
-impl DepGraphSafe for DefId {}
-
-/// Tuples make it easy to build up state.
-impl<A, B> DepGraphSafe for (A, B)
-where
- A: DepGraphSafe,
- B: DepGraphSafe,
-{
-}
-
-/// Shared ref to dep-graph-safe stuff should still be dep-graph-safe.
-impl<'a, A> DepGraphSafe for &'a A where A: DepGraphSafe {}
-
-/// Mut ref to dep-graph-safe stuff should still be dep-graph-safe.
-impl<'a, A> DepGraphSafe for &'a mut A where A: DepGraphSafe {}
-
-/// No data here! :)
-impl DepGraphSafe for () {}
-
-/// A convenient override that lets you pass arbitrary state into a
-/// task. Every use should be accompanied by a comment explaining why
-/// it makes sense (or how it could be refactored away in the future).
-pub struct AssertDepGraphSafe<T>(pub T);
-
-impl<T> DepGraphSafe for AssertDepGraphSafe<T> {}
pub trait HashStableContext {
fn debug_dep_tasks(&self) -> bool;
}
-
-/// Something that can provide a stable hashing context.
-pub trait HashStableContextProvider<Ctxt> {
- fn get_stable_hashing_context(&self) -> Ctxt;
-}
-
-impl<Ctxt, T: HashStableContextProvider<Ctxt>> HashStableContextProvider<Ctxt> for &T {
- fn get_stable_hashing_context(&self) -> Ctxt {
- (**self).get_stable_hashing_context()
- }
-}
-
-impl<Ctxt, T: HashStableContextProvider<Ctxt>> HashStableContextProvider<Ctxt> for &mut T {
- fn get_stable_hashing_context(&self) -> Ctxt {
- (**self).get_stable_hashing_context()
- }
-}
//! generate the actual methods on tcx which find and execute the provider,
//! manage the caches, and so forth.
-use crate::dep_graph::{DepContext, DepKind, DepNode};
+use crate::dep_graph::{DepKind, DepNode};
use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
use crate::query::caches::QueryCache;
use crate::query::config::{QueryContext, QueryDescription};
use crate::query::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryShardJobId};
-use crate::HashStableContextProvider;
#[cfg(not(parallel_compiler))]
use rustc_data_structures::cold_path;
}
#[inline(always)]
-fn try_execute_query<Q, CTX, K>(
+fn try_execute_query<Q, CTX>(
tcx: CTX,
span: Span,
key: Q::Key,
) -> Q::Value
where
Q: QueryDescription<CTX>,
- CTX: QueryContext<DepKind = K>,
- CTX: HashStableContextProvider<<CTX as DepContext>::StableHashingContext>,
- K: DepKind,
+ CTX: QueryContext,
{
let job = match JobOwner::try_start::<Q, _>(tcx, span, &key, lookup) {
TryGetJob::NotYetStarted(job) => job,
// expensive for some `DepKind`s.
if !tcx.dep_graph().is_fully_enabled() {
let null_dep_node = DepNode::new_no_params(DepKind::NULL);
- return force_query_with_job::<Q, _, _>(tcx, key, job, null_dep_node).0;
+ return force_query_with_job::<Q, _>(tcx, key, job, null_dep_node).0;
}
if Q::ANON {
}
}
- let (result, dep_node_index) = force_query_with_job::<Q, _, _>(tcx, key, job, dep_node);
+ let (result, dep_node_index) = force_query_with_job::<Q, _>(tcx, key, job, dep_node);
tcx.dep_graph().read_index(dep_node_index);
result
}
}
#[inline(always)]
-fn force_query_with_job<Q, CTX, K>(
+fn force_query_with_job<Q, CTX>(
tcx: CTX,
key: Q::Key,
job: JobOwner<'_, CTX, Q::Cache>,
) -> (Q::Value, DepNodeIndex)
where
Q: QueryDescription<CTX>,
- CTX: QueryContext<DepKind = K>,
- CTX: HashStableContextProvider<<CTX as DepContext>::StableHashingContext>,
- K: DepKind,
+ CTX: QueryContext,
{
// If the following assertion triggers, it can have two reasons:
// 1. Something is wrong with DepNode creation, either here or
);
}
-impl<CTX, K> QueryGetter for CTX
+impl<CTX> QueryGetter for CTX
where
- CTX: QueryContext<DepKind = K>,
- CTX: HashStableContextProvider<<CTX as DepContext>::StableHashingContext>,
- K: DepKind,
+ CTX: QueryContext,
{
#[inline(never)]
fn get_query<Q: QueryDescription<Self>>(self, span: Span, key: Q::Key) -> Q::Value {
self.dep_graph().read_index(index);
value.clone()
},
- |key, lookup| try_execute_query::<Q, _, _>(self, span, key, lookup),
+ |key, lookup| try_execute_query::<Q, _>(self, span, key, lookup),
)
}
#[cfg(parallel_compiler)]
TryGetJob::JobCompleted(_) => return,
};
- force_query_with_job::<Q, _, _>(self, key, job, dep_node);
+ force_query_with_job::<Q, _>(self, key, job, dep_node);
},
);
}