From 222d01025581174b4f6c1afacf673bc6eade3a6a Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 27 Mar 2020 07:50:28 +0100 Subject: [PATCH] Cleanups. --- src/librustc/dep_graph/mod.rs | 10 +++++----- src/librustc/ty/query/plumbing.rs | 10 +++++----- src/librustc_query_system/dep_graph/graph.rs | 3 +-- src/librustc_query_system/dep_graph/mod.rs | 2 ++ src/librustc_query_system/lib.rs | 4 +--- 5 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/librustc/dep_graph/mod.rs b/src/librustc/dep_graph/mod.rs index de94b6b1850d7..7b05a575b93a8 100644 --- a/src/librustc/dep_graph/mod.rs +++ b/src/librustc/dep_graph/mod.rs @@ -95,6 +95,10 @@ impl<'tcx> DepContext for TyCtxt<'tcx> { TyCtxt::create_stable_hashing_context(*self) } + fn debug_dep_tasks(&self) -> bool { + self.sess.opts.debugging_opts.dep_tasks + } + fn try_force_from_dep_node(&self, dep_node: &DepNode) -> bool { // FIXME: This match is just a workaround for incremental bugs and should // be removed. https://github.com/rust-lang/rust/issues/62649 is one such @@ -181,8 +185,4 @@ fn def_id_corresponds_to_hir_dep_node(tcx: TyCtxt<'_>, def_id: DefId) -> bool { def_id.index == hir_id.owner.local_def_index } -impl rustc_query_system::HashStableContext for StableHashingContext<'_> { - fn debug_dep_tasks(&self) -> bool { - self.sess().opts.debugging_opts.dep_tasks - } -} +impl rustc_query_system::HashStableContext for StableHashingContext<'_> {} diff --git a/src/librustc/ty/query/plumbing.rs b/src/librustc/ty/query/plumbing.rs index 0fabacb5f69fd..1bb392f436fc6 100644 --- a/src/librustc/ty/query/plumbing.rs +++ b/src/librustc/ty/query/plumbing.rs @@ -209,14 +209,14 @@ macro_rules! is_eval_always { } macro_rules! query_storage { - (<$tcx:tt>[][$K:ty, $V:ty]) => { + ([][$K:ty, $V:ty]) => { <<$K as Key>::CacheSelector as CacheSelector<$K, $V>>::Cache }; - (<$tcx:tt>[storage($ty:ty) $($rest:tt)*][$K:ty, $V:ty]) => { + ([storage($ty:ty) $($rest:tt)*][$K:ty, $V:ty]) => { $ty }; - (<$tcx:tt>[$other:ident $(($($other_args:tt)*))* $(, $($modifiers:tt)*)*][$($args:tt)*]) => { - query_storage!(<$tcx>[$($($modifiers)*)*][$($args)*]) + ([$other:ident $(($($other_args:tt)*))* $(, $($modifiers:tt)*)*][$($args:tt)*]) => { + query_storage!([$($($modifiers)*)*][$($args)*]) }; } @@ -332,7 +332,7 @@ macro_rules! define_queries_inner { const EVAL_ALWAYS: bool = is_eval_always!([$($modifiers)*]); const DEP_KIND: dep_graph::DepKind = dep_graph::DepKind::$node; - type Cache = query_storage!(<$tcx>[$($modifiers)*][$K, $V]); + type Cache = query_storage!([$($modifiers)*][$K, $V]); #[inline(always)] fn query_state<'a>(tcx: TyCtxt<$tcx>) -> &'a QueryState, Self::Cache> { diff --git a/src/librustc_query_system/dep_graph/graph.rs b/src/librustc_query_system/dep_graph/graph.rs index 60c5dcda42515..73983e1644cb0 100644 --- a/src/librustc_query_system/dep_graph/graph.rs +++ b/src/librustc_query_system/dep_graph/graph.rs @@ -22,7 +22,6 @@ use super::prev::PreviousDepGraph; use super::query::DepGraphQuery; use super::serialized::{SerializedDepGraph, SerializedDepNodeIndex}; use super::{DepContext, DepKind, DepNode, WorkProductId}; -use crate::HashStableContext; #[derive(Clone)] pub struct DepGraph { @@ -259,7 +258,7 @@ impl DepGraph { task_deps.map(|lock| lock.into_inner()), ); - let print_status = cfg!(debug_assertions) && hcx.debug_dep_tasks(); + let print_status = cfg!(debug_assertions) && cx.debug_dep_tasks(); // Determine the color of the new DepNode. if let Some(prev_index) = data.previous.node_to_index_opt(&key) { diff --git a/src/librustc_query_system/dep_graph/mod.rs b/src/librustc_query_system/dep_graph/mod.rs index f215dadc6608f..232efa8795d24 100644 --- a/src/librustc_query_system/dep_graph/mod.rs +++ b/src/librustc_query_system/dep_graph/mod.rs @@ -27,6 +27,8 @@ pub trait DepContext: Copy { /// Create a hashing context for hashing new results. fn create_stable_hashing_context(&self) -> Self::StableHashingContext; + fn debug_dep_tasks(&self) -> bool; + /// Try to force a dep node to execute and see if it's green. fn try_force_from_dep_node(&self, dep_node: &DepNode) -> bool; diff --git a/src/librustc_query_system/lib.rs b/src/librustc_query_system/lib.rs index 1f7fde642eb41..6623e74b5cb18 100644 --- a/src/librustc_query_system/lib.rs +++ b/src/librustc_query_system/lib.rs @@ -16,6 +16,4 @@ extern crate rustc_data_structures; pub mod dep_graph; pub mod query; -pub trait HashStableContext { - fn debug_dep_tasks(&self) -> bool; -} +pub trait HashStableContext {}