diff options
| author | Camille GILLOT <gillot.camille@gmail.com> | 2020-11-02 23:09:03 +0100 |
|---|---|---|
| committer | Camille GILLOT <gillot.camille@gmail.com> | 2021-08-22 20:23:29 +0200 |
| commit | c3bf3969d408f46881908336f9e3a8721601abc4 (patch) | |
| tree | a8a4157db967e1c1950be784c42de482cb04dae2 | |
| parent | cd1cb3449e3c92f6fbcd907d58b3009b1067d7f0 (diff) | |
| download | rust-c3bf3969d408f46881908336f9e3a8721601abc4.tar.gz rust-c3bf3969d408f46881908336f9e3a8721601abc4.zip | |
Move assertion inwards.
`with_taks_impl` is only called from `with_eval_always_task` and `with_task` . The former is only used in query invocation, while the latter is also used to start the `tcx` and to trigger codegen. This move should not change significantly the number of calls to this assertion.
| -rw-r--r-- | compiler/rustc_query_system/src/dep_graph/graph.rs | 21 | ||||
| -rw-r--r-- | compiler/rustc_query_system/src/query/plumbing.rs | 14 |
2 files changed, 18 insertions, 17 deletions
diff --git a/compiler/rustc_query_system/src/dep_graph/graph.rs b/compiler/rustc_query_system/src/dep_graph/graph.rs index 9c3dad8bd63..21f9d51e7af 100644 --- a/compiler/rustc_query_system/src/dep_graph/graph.rs +++ b/compiler/rustc_query_system/src/dep_graph/graph.rs @@ -11,6 +11,7 @@ use rustc_serialize::opaque::{FileEncodeResult, FileEncoder}; use parking_lot::Mutex; use smallvec::{smallvec, SmallVec}; use std::collections::hash_map::Entry; +use std::fmt::Debug; use std::hash::Hash; use std::marker::PhantomData; use std::sync::atomic::Ordering::Relaxed; @@ -208,7 +209,7 @@ impl<K: DepKind> DepGraph<K> { /// `arg` parameter. /// /// [rustc dev guide]: https://rustc-dev-guide.rust-lang.org/incremental-compilation.html - pub fn with_task<Ctxt: HasDepContext<DepKind = K>, A, R>( + pub fn with_task<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>( &self, key: DepNode<K>, cx: Ctxt, @@ -234,7 +235,7 @@ impl<K: DepKind> DepGraph<K> { ) } - fn with_task_impl<Ctxt: HasDepContext<DepKind = K>, A, R>( + fn with_task_impl<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>( &self, key: DepNode<K>, cx: Ctxt, @@ -244,6 +245,20 @@ impl<K: DepKind> DepGraph<K> { hash_result: impl FnOnce(&mut Ctxt::StableHashingContext, &R) -> Option<Fingerprint>, ) -> (R, DepNodeIndex) { if let Some(ref data) = self.data { + // If the following assertion triggers, it can have two reasons: + // 1. Something is wrong with DepNode creation, either here or + // in `DepGraph::try_mark_green()`. + // 2. Two distinct query keys get mapped to the same `DepNode` + // (see for example #48923). + assert!( + !self.dep_node_exists(&key), + "forcing query with already existing `DepNode`\n\ + - query-key: {:?}\n\ + - dep-node: {:?}", + arg, + key + ); + let dcx = cx.dep_context(); let task_deps = create_task(key).map(Lock::new); let result = K::with_deps(task_deps.as_ref(), || task(cx, arg)); @@ -359,7 +374,7 @@ impl<K: DepKind> DepGraph<K> { /// Executes something within an "eval-always" task which is a task /// that runs whenever anything changes. - pub fn with_eval_always_task<Ctxt: HasDepContext<DepKind = K>, A, R>( + pub fn with_eval_always_task<Ctxt: HasDepContext<DepKind = K>, A: Debug, R>( &self, key: DepNode<K>, cx: Ctxt, diff --git a/compiler/rustc_query_system/src/query/plumbing.rs b/compiler/rustc_query_system/src/query/plumbing.rs index 55739cbf1d8..86097042da0 100644 --- a/compiler/rustc_query_system/src/query/plumbing.rs +++ b/compiler/rustc_query_system/src/query/plumbing.rs @@ -646,20 +646,6 @@ where C: QueryCache, CTX: QueryContext, { - // If the following assertion triggers, it can have two reasons: - // 1. Something is wrong with DepNode creation, either here or - // in `DepGraph::try_mark_green()`. - // 2. Two distinct query keys get mapped to the same `DepNode` - // (see for example #48923). - assert!( - !tcx.dep_context().dep_graph().dep_node_exists(&dep_node), - "forcing query with already existing `DepNode`\n\ - - query-key: {:?}\n\ - - dep-node: {:?}", - key, - dep_node - ); - let prof_timer = tcx.dep_context().profiler().query_provider(); let ((result, dep_node_index), diagnostics) = with_diagnostics(|diagnostics| { |
