From db5be1fe208d0cbdde750a0eb9f01bbd8afda1ee Mon Sep 17 00:00:00 2001 From: Camille GILLOT Date: Fri, 27 Mar 2020 07:43:11 +0100 Subject: [PATCH] Move QueryContext to the parent module. --- src/librustc_query_system/query/caches.rs | 2 +- src/librustc_query_system/query/config.rs | 40 +------------------- src/librustc_query_system/query/job.rs | 2 +- src/librustc_query_system/query/mod.rs | 41 ++++++++++++++++++++- src/librustc_query_system/query/plumbing.rs | 3 +- 5 files changed, 46 insertions(+), 42 deletions(-) diff --git a/src/librustc_query_system/query/caches.rs b/src/librustc_query_system/query/caches.rs index 51bea58fd80..0c0335ba04f 100644 --- a/src/librustc_query_system/query/caches.rs +++ b/src/librustc_query_system/query/caches.rs @@ -1,6 +1,6 @@ use crate::dep_graph::DepNodeIndex; -use crate::query::config::QueryContext; use crate::query::plumbing::{QueryLookup, QueryState}; +use crate::query::QueryContext; use rustc_data_structures::fx::FxHashMap; use rustc_data_structures::sharded::Sharded; diff --git a/src/librustc_query_system/query/config.rs b/src/librustc_query_system/query/config.rs index 46a48a31161..20dad0bd47e 100644 --- a/src/librustc_query_system/query/config.rs +++ b/src/librustc_query_system/query/config.rs @@ -1,20 +1,14 @@ //! Query configuration and description traits. +use crate::dep_graph::DepNode; use crate::dep_graph::SerializedDepNodeIndex; -use crate::dep_graph::{DepContext, DepGraph, DepNode}; use crate::query::caches::QueryCache; -use crate::query::job::{QueryJobId, QueryJobInfo}; use crate::query::plumbing::CycleError; -use crate::query::QueryState; +use crate::query::{QueryContext, QueryState}; use rustc_data_structures::profiling::ProfileCategory; use rustc_span::def_id::DefId; use rustc_data_structures::fingerprint::Fingerprint; -use rustc_data_structures::fx::FxHashMap; -use rustc_data_structures::stable_hasher::HashStable; -use rustc_data_structures::sync::Lock; -use rustc_data_structures::thin_vec::ThinVec; -use rustc_errors::Diagnostic; use std::borrow::Cow; use std::fmt::Debug; use std::hash::Hash; @@ -29,36 +23,6 @@ pub trait QueryConfig { type Value: Clone; } -pub trait QueryContext: DepContext { - type Query: Clone + HashStable; - - fn incremental_verify_ich(&self) -> bool; - fn verbose(&self) -> bool; - - /// Get string representation from DefPath. - fn def_path_str(&self, def_id: DefId) -> String; - - /// Access the DepGraph. - fn dep_graph(&self) -> &DepGraph; - - /// Get the query information from the TLS context. - fn current_query_job(&self) -> Option>; - - fn try_collect_active_jobs( - &self, - ) -> Option, QueryJobInfo>>; - - /// Executes a job by changing the `ImplicitCtxt` to point to the - /// new query job while it executes. It returns the diagnostics - /// captured during execution and the actual result. - fn start_query( - &self, - token: QueryJobId, - diagnostics: Option<&Lock>>, - compute: impl FnOnce(Self) -> R, - ) -> R; -} - pub trait QueryAccessors: QueryConfig { const ANON: bool; const EVAL_ALWAYS: bool; diff --git a/src/librustc_query_system/query/job.rs b/src/librustc_query_system/query/job.rs index a7488b6fdff..de6dc81d868 100644 --- a/src/librustc_query_system/query/job.rs +++ b/src/librustc_query_system/query/job.rs @@ -1,6 +1,6 @@ use crate::dep_graph::{DepContext, DepKind}; -use crate::query::config::QueryContext; use crate::query::plumbing::CycleError; +use crate::query::QueryContext; use rustc_data_structures::fx::FxHashMap; use rustc_span::Span; diff --git a/src/librustc_query_system/query/mod.rs b/src/librustc_query_system/query/mod.rs index 9d0a6665eac..b1677c5c93d 100644 --- a/src/librustc_query_system/query/mod.rs +++ b/src/librustc_query_system/query/mod.rs @@ -10,4 +10,43 @@ pub use self::caches::{CacheSelector, DefaultCacheSelector, QueryCache}; mod config; -pub use self::config::{QueryAccessors, QueryConfig, QueryContext, QueryDescription}; +pub use self::config::{QueryAccessors, QueryConfig, QueryDescription}; + +use crate::dep_graph::{DepContext, DepGraph}; + +use rustc_data_structures::fx::FxHashMap; +use rustc_data_structures::stable_hasher::HashStable; +use rustc_data_structures::sync::Lock; +use rustc_data_structures::thin_vec::ThinVec; +use rustc_errors::Diagnostic; +use rustc_span::def_id::DefId; + +pub trait QueryContext: DepContext { + type Query: Clone + HashStable; + + fn incremental_verify_ich(&self) -> bool; + fn verbose(&self) -> bool; + + /// Get string representation from DefPath. + fn def_path_str(&self, def_id: DefId) -> String; + + /// Access the DepGraph. + fn dep_graph(&self) -> &DepGraph; + + /// Get the query information from the TLS context. + fn current_query_job(&self) -> Option>; + + fn try_collect_active_jobs( + &self, + ) -> Option, QueryJobInfo>>; + + /// Executes a job by changing the `ImplicitCtxt` to point to the + /// new query job while it executes. It returns the diagnostics + /// captured during execution and the actual result. + fn start_query( + &self, + token: QueryJobId, + diagnostics: Option<&Lock>>, + compute: impl FnOnce(Self) -> R, + ) -> R; +} diff --git a/src/librustc_query_system/query/plumbing.rs b/src/librustc_query_system/query/plumbing.rs index bec45b29d30..b371a914c6f 100644 --- a/src/librustc_query_system/query/plumbing.rs +++ b/src/librustc_query_system/query/plumbing.rs @@ -5,8 +5,9 @@ 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::config::QueryDescription; use crate::query::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryShardJobId}; +use crate::query::QueryContext; #[cfg(not(parallel_compiler))] use rustc_data_structures::cold_path; -- 2.44.0