Skip to content

Commit db5be1f

Browse files
committed
Move QueryContext to the parent module.
1 parent 4faf701 commit db5be1f

File tree

5 files changed

+46
-42
lines changed

5 files changed

+46
-42
lines changed

src/librustc_query_system/query/caches.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::dep_graph::DepNodeIndex;
2-
use crate::query::config::QueryContext;
32
use crate::query::plumbing::{QueryLookup, QueryState};
3+
use crate::query::QueryContext;
44

55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_data_structures::sharded::Sharded;

src/librustc_query_system/query/config.rs

+2-38
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,14 @@
11
//! Query configuration and description traits.
22
3+
use crate::dep_graph::DepNode;
34
use crate::dep_graph::SerializedDepNodeIndex;
4-
use crate::dep_graph::{DepContext, DepGraph, DepNode};
55
use crate::query::caches::QueryCache;
6-
use crate::query::job::{QueryJobId, QueryJobInfo};
76
use crate::query::plumbing::CycleError;
8-
use crate::query::QueryState;
7+
use crate::query::{QueryContext, QueryState};
98
use rustc_data_structures::profiling::ProfileCategory;
109
use rustc_span::def_id::DefId;
1110

1211
use rustc_data_structures::fingerprint::Fingerprint;
13-
use rustc_data_structures::fx::FxHashMap;
14-
use rustc_data_structures::stable_hasher::HashStable;
15-
use rustc_data_structures::sync::Lock;
16-
use rustc_data_structures::thin_vec::ThinVec;
17-
use rustc_errors::Diagnostic;
1812
use std::borrow::Cow;
1913
use std::fmt::Debug;
2014
use std::hash::Hash;
@@ -29,36 +23,6 @@ pub trait QueryConfig<CTX> {
2923
type Value: Clone;
3024
}
3125

32-
pub trait QueryContext: DepContext {
33-
type Query: Clone + HashStable<Self::StableHashingContext>;
34-
35-
fn incremental_verify_ich(&self) -> bool;
36-
fn verbose(&self) -> bool;
37-
38-
/// Get string representation from DefPath.
39-
fn def_path_str(&self, def_id: DefId) -> String;
40-
41-
/// Access the DepGraph.
42-
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
43-
44-
/// Get the query information from the TLS context.
45-
fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;
46-
47-
fn try_collect_active_jobs(
48-
&self,
49-
) -> Option<FxHashMap<QueryJobId<Self::DepKind>, QueryJobInfo<Self>>>;
50-
51-
/// Executes a job by changing the `ImplicitCtxt` to point to the
52-
/// new query job while it executes. It returns the diagnostics
53-
/// captured during execution and the actual result.
54-
fn start_query<R>(
55-
&self,
56-
token: QueryJobId<Self::DepKind>,
57-
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
58-
compute: impl FnOnce(Self) -> R,
59-
) -> R;
60-
}
61-
6226
pub trait QueryAccessors<CTX: QueryContext>: QueryConfig<CTX> {
6327
const ANON: bool;
6428
const EVAL_ALWAYS: bool;

src/librustc_query_system/query/job.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::dep_graph::{DepContext, DepKind};
2-
use crate::query::config::QueryContext;
32
use crate::query::plumbing::CycleError;
3+
use crate::query::QueryContext;
44

55
use rustc_data_structures::fx::FxHashMap;
66
use rustc_span::Span;

src/librustc_query_system/query/mod.rs

+40-1
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,43 @@ mod caches;
1010
pub use self::caches::{CacheSelector, DefaultCacheSelector, QueryCache};
1111

1212
mod config;
13-
pub use self::config::{QueryAccessors, QueryConfig, QueryContext, QueryDescription};
13+
pub use self::config::{QueryAccessors, QueryConfig, QueryDescription};
14+
15+
use crate::dep_graph::{DepContext, DepGraph};
16+
17+
use rustc_data_structures::fx::FxHashMap;
18+
use rustc_data_structures::stable_hasher::HashStable;
19+
use rustc_data_structures::sync::Lock;
20+
use rustc_data_structures::thin_vec::ThinVec;
21+
use rustc_errors::Diagnostic;
22+
use rustc_span::def_id::DefId;
23+
24+
pub trait QueryContext: DepContext {
25+
type Query: Clone + HashStable<Self::StableHashingContext>;
26+
27+
fn incremental_verify_ich(&self) -> bool;
28+
fn verbose(&self) -> bool;
29+
30+
/// Get string representation from DefPath.
31+
fn def_path_str(&self, def_id: DefId) -> String;
32+
33+
/// Access the DepGraph.
34+
fn dep_graph(&self) -> &DepGraph<Self::DepKind>;
35+
36+
/// Get the query information from the TLS context.
37+
fn current_query_job(&self) -> Option<QueryJobId<Self::DepKind>>;
38+
39+
fn try_collect_active_jobs(
40+
&self,
41+
) -> Option<FxHashMap<QueryJobId<Self::DepKind>, QueryJobInfo<Self>>>;
42+
43+
/// Executes a job by changing the `ImplicitCtxt` to point to the
44+
/// new query job while it executes. It returns the diagnostics
45+
/// captured during execution and the actual result.
46+
fn start_query<R>(
47+
&self,
48+
token: QueryJobId<Self::DepKind>,
49+
diagnostics: Option<&Lock<ThinVec<Diagnostic>>>,
50+
compute: impl FnOnce(Self) -> R,
51+
) -> R;
52+
}

src/librustc_query_system/query/plumbing.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,9 @@
55
use crate::dep_graph::{DepKind, DepNode};
66
use crate::dep_graph::{DepNodeIndex, SerializedDepNodeIndex};
77
use crate::query::caches::QueryCache;
8-
use crate::query::config::{QueryContext, QueryDescription};
8+
use crate::query::config::QueryDescription;
99
use crate::query::job::{QueryInfo, QueryJob, QueryJobId, QueryJobInfo, QueryShardJobId};
10+
use crate::query::QueryContext;
1011

1112
#[cfg(not(parallel_compiler))]
1213
use rustc_data_structures::cold_path;

0 commit comments

Comments
 (0)