Skip to content

Commit 0bf7c2a

Browse files
committed
Auto merge of rust-lang#70162 - cjgillot:split_query, r=Zoxc
Move the query system to a dedicated crate The query system `rustc::ty::query` is split out into the `rustc_query_system` crate. Some commits are unformatted, to ease rebasing. Based on rust-lang#67761 and rust-lang#69910. r? @Zoxc
2 parents 7520894 + 2d7bbda commit 0bf7c2a

File tree

28 files changed

+1556
-1529
lines changed

28 files changed

+1556
-1529
lines changed

Cargo.lock

+2-2
Original file line numberDiff line numberDiff line change
@@ -4081,12 +4081,12 @@ version = "0.0.0"
40814081
dependencies = [
40824082
"log",
40834083
"parking_lot 0.9.0",
4084-
"rustc_ast",
4084+
"rustc-rayon-core",
40854085
"rustc_data_structures",
40864086
"rustc_errors",
4087-
"rustc_hir",
40884087
"rustc_index",
40894088
"rustc_macros",
4089+
"rustc_span",
40904090
"serialize",
40914091
"smallvec 1.0.0",
40924092
]

src/librustc/dep_graph/mod.rs

+18-23
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@ use rustc_errors::Diagnostic;
88
use rustc_hir::def_id::DefId;
99

1010
mod dep_node;
11-
mod safe;
1211

1312
pub(crate) use rustc_query_system::dep_graph::DepNodeParams;
1413
pub use rustc_query_system::dep_graph::{
@@ -17,8 +16,6 @@ pub use rustc_query_system::dep_graph::{
1716
};
1817

1918
pub use dep_node::{label_strs, DepConstructor, DepKind, DepNode, DepNodeExt};
20-
pub use safe::AssertDepGraphSafe;
21-
pub use safe::DepGraphSafe;
2219

2320
pub type DepGraph = rustc_query_system::dep_graph::DepGraph<DepKind>;
2421
pub type TaskDeps = rustc_query_system::dep_graph::TaskDeps<DepKind>;
@@ -27,6 +24,8 @@ pub type PreviousDepGraph = rustc_query_system::dep_graph::PreviousDepGraph<DepK
2724
pub type SerializedDepGraph = rustc_query_system::dep_graph::SerializedDepGraph<DepKind>;
2825

2926
impl rustc_query_system::dep_graph::DepKind for DepKind {
27+
const NULL: Self = DepKind::Null;
28+
3029
fn is_eval_always(&self) -> bool {
3130
DepKind::is_eval_always(self)
3231
}
@@ -82,6 +81,10 @@ impl rustc_query_system::dep_graph::DepKind for DepKind {
8281
op(icx.task_deps)
8382
})
8483
}
84+
85+
fn can_reconstruct_query_key(&self) -> bool {
86+
DepKind::can_reconstruct_query_key(self)
87+
}
8588
}
8689

8790
impl<'tcx> DepContext for TyCtxt<'tcx> {
@@ -92,6 +95,10 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
9295
TyCtxt::create_stable_hashing_context(*self)
9396
}
9497

98+
fn debug_dep_tasks(&self) -> bool {
99+
self.sess.opts.debugging_opts.dep_tasks
100+
}
101+
95102
fn try_force_from_dep_node(&self, dep_node: &DepNode) -> bool {
96103
// FIXME: This match is just a workaround for incremental bugs and should
97104
// be removed. https://github.com/rust-lang/rust/issues/62649 is one such
@@ -160,6 +167,14 @@ impl<'tcx> DepContext for TyCtxt<'tcx> {
160167
self.queries.on_disk_cache.store_diagnostics(dep_node_index, diagnostics)
161168
}
162169

170+
fn store_diagnostics_for_anon_node(
171+
&self,
172+
dep_node_index: DepNodeIndex,
173+
diagnostics: ThinVec<Diagnostic>,
174+
) {
175+
self.queries.on_disk_cache.store_diagnostics_for_anon_node(dep_node_index, diagnostics)
176+
}
177+
163178
fn profiler(&self) -> &SelfProfilerRef {
164179
&self.prof
165180
}
@@ -169,23 +184,3 @@ fn def_id_corresponds_to_hir_dep_node(tcx: TyCtxt<'_>, def_id: DefId) -> bool {
169184
let hir_id = tcx.hir().as_local_hir_id(def_id).unwrap();
170185
def_id.index == hir_id.owner.local_def_index
171186
}
172-
173-
impl rustc_query_system::HashStableContext for StableHashingContext<'_> {
174-
fn debug_dep_tasks(&self) -> bool {
175-
self.sess().opts.debugging_opts.dep_tasks
176-
}
177-
}
178-
179-
impl rustc_query_system::HashStableContextProvider<StableHashingContext<'tcx>> for TyCtxt<'tcx> {
180-
fn get_stable_hashing_context(&self) -> StableHashingContext<'tcx> {
181-
self.create_stable_hashing_context()
182-
}
183-
}
184-
185-
impl rustc_query_system::HashStableContextProvider<StableHashingContext<'a>>
186-
for StableHashingContext<'a>
187-
{
188-
fn get_stable_hashing_context(&self) -> Self {
189-
self.clone()
190-
}
191-
}

src/librustc/dep_graph/safe.rs

-9
This file was deleted.

src/librustc/ich/hcx.rs

-2
Original file line numberDiff line numberDiff line change
@@ -194,8 +194,6 @@ impl<'a> StableHashingContextProvider<'a> for StableHashingContext<'a> {
194194
}
195195
}
196196

197-
impl<'a> crate::dep_graph::DepGraphSafe for StableHashingContext<'a> {}
198-
199197
impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
200198
fn hash_stable(&self, _: &mut StableHashingContext<'a>, _: &mut StableHasher) {
201199
panic!("Node IDs should not appear in incremental state");

src/librustc/ty/context.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1603,7 +1603,7 @@ nop_list_lift! {substs; GenericArg<'a> => GenericArg<'tcx>}
16031603
pub mod tls {
16041604
use super::{ptr_eq, GlobalCtxt, TyCtxt};
16051605

1606-
use crate::dep_graph::TaskDeps;
1606+
use crate::dep_graph::{DepKind, TaskDeps};
16071607
use crate::ty::query;
16081608
use rustc_data_structures::sync::{self, Lock};
16091609
use rustc_data_structures::thin_vec::ThinVec;
@@ -1630,7 +1630,7 @@ pub mod tls {
16301630

16311631
/// The current query job, if any. This is updated by `JobOwner::start` in
16321632
/// `ty::query::plumbing` when executing a query.
1633-
pub query: Option<query::QueryJobId>,
1633+
pub query: Option<query::QueryJobId<DepKind>>,
16341634

16351635
/// Where to store diagnostics for the current query job, if any.
16361636
/// This is updated by `JobOwner::start` in `ty::query::plumbing` when executing a query.

src/librustc/ty/query/config.rs

-82
This file was deleted.

0 commit comments

Comments
 (0)