Move QueryContext to the parent module.
This commit is contained in:
parent
4faf701d20
commit
db5be1fe20
5 changed files with 46 additions and 42 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -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<CTX> {
|
|||
type Value: Clone;
|
||||
}
|
||||
|
||||
pub trait QueryContext: DepContext {
|
||||
type Query: Clone + HashStable<Self::StableHashingContext>;
|
||||
|
||||
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<Self::DepKind>;
|
||||
|
||||
/// Get the query information from the TLS context.
|
||||
fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;
|
||||
|
||||
fn try_collect_active_jobs(
|
||||
&self,
|
||||
) -> Option<FxHashMap<QueryJobId<Self::DepKind>, QueryJobInfo<Self>>>;
|
||||
|
||||
/// 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<R>(
|
||||
&self,
|
||||
token: QueryJobId<Self::DepKind>,
|
||||
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
|
||||
compute: impl FnOnce(Self) -> R,
|
||||
) -> R;
|
||||
}
|
||||
|
||||
pub trait QueryAccessors<CTX: QueryContext>: QueryConfig<CTX> {
|
||||
const ANON: bool;
|
||||
const EVAL_ALWAYS: bool;
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -10,4 +10,43 @@ mod caches;
|
|||
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<Self::StableHashingContext>;
|
||||
|
||||
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<Self::DepKind>;
|
||||
|
||||
/// Get the query information from the TLS context.
|
||||
fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;
|
||||
|
||||
fn try_collect_active_jobs(
|
||||
&self,
|
||||
) -> Option<FxHashMap<QueryJobId<Self::DepKind>, QueryJobInfo<Self>>>;
|
||||
|
||||
/// 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<R>(
|
||||
&self,
|
||||
token: QueryJobId<Self::DepKind>,
|
||||
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
|
||||
compute: impl FnOnce(Self) -> R,
|
||||
) -> R;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue