Skip to content

Commit 45add98

Browse files
authored
Rollup merge of rust-lang#152703 - nnethercote:rm-rustc_query_system, r=Zalathar
Remove `rustc_query_system` The end point of the PR sequence rust-lang#152160, rust-lang#152419, rust-lang#152516. r? @Zalathar
2 parents 0582976 + e9288e7 commit 45add98

44 files changed

Lines changed: 83 additions & 185 deletions

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

Cargo.lock

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -3640,7 +3640,6 @@ dependencies = [
36403640
"rustc_macros",
36413641
"rustc_metadata",
36423642
"rustc_middle",
3643-
"rustc_query_system",
36443643
"rustc_sanitizers",
36453644
"rustc_session",
36463645
"rustc_span",
@@ -4243,7 +4242,6 @@ dependencies = [
42434242
"rustc_index",
42444243
"rustc_lint_defs",
42454244
"rustc_macros",
4246-
"rustc_query_system",
42474245
"rustc_serialize",
42484246
"rustc_session",
42494247
"rustc_span",
@@ -4507,23 +4505,6 @@ dependencies = [
45074505
"tracing",
45084506
]
45094507

4510-
[[package]]
4511-
name = "rustc_query_system"
4512-
version = "0.0.0"
4513-
dependencies = [
4514-
"rustc_abi",
4515-
"rustc_ast",
4516-
"rustc_data_structures",
4517-
"rustc_errors",
4518-
"rustc_feature",
4519-
"rustc_hir",
4520-
"rustc_macros",
4521-
"rustc_serialize",
4522-
"rustc_session",
4523-
"rustc_span",
4524-
"smallvec",
4525-
]
4526-
45274508
[[package]]
45284509
name = "rustc_resolve"
45294510
version = "0.0.0"

compiler/rustc_codegen_llvm/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@ rustc_llvm = { path = "../rustc_llvm" }
3131
rustc_macros = { path = "../rustc_macros" }
3232
rustc_metadata = { path = "../rustc_metadata" }
3333
rustc_middle = { path = "../rustc_middle" }
34-
rustc_query_system = { path = "../rustc_query_system" }
3534
rustc_sanitizers = { path = "../rustc_sanitizers" }
3635
rustc_session = { path = "../rustc_session" }
3736
rustc_span = { path = "../rustc_span" }

compiler/rustc_interface/src/callbacks.rs

Lines changed: 3 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,8 @@
1111
1212
use std::fmt;
1313

14-
use rustc_errors::{DiagInner, TRACK_DIAGNOSTIC};
15-
use rustc_middle::dep_graph::dep_node::default_dep_kind_debug;
16-
use rustc_middle::dep_graph::{DepKind, DepNode, TaskDepsRef};
14+
use rustc_errors::DiagInner;
15+
use rustc_middle::dep_graph::TaskDepsRef;
1716
use rustc_middle::ty::tls;
1817

1918
fn track_span_parent(def_id: rustc_span::def_id::LocalDefId) {
@@ -65,49 +64,10 @@ fn def_id_debug(def_id: rustc_hir::def_id::DefId, f: &mut fmt::Formatter<'_>) ->
6564
write!(f, ")")
6665
}
6766

68-
/// This is a callback from `rustc_query_system` as it cannot access the implicit state
69-
/// in `rustc_middle` otherwise.
70-
pub fn dep_kind_debug(kind: DepKind, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
71-
tls::with_opt(|opt_tcx| {
72-
if let Some(tcx) = opt_tcx {
73-
write!(f, "{}", tcx.dep_kind_vtable(kind).name)
74-
} else {
75-
default_dep_kind_debug(kind, f)
76-
}
77-
})
78-
}
79-
80-
/// This is a callback from `rustc_query_system` as it cannot access the implicit state
81-
/// in `rustc_middle` otherwise.
82-
pub fn dep_node_debug(node: DepNode, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
83-
write!(f, "{:?}(", node.kind)?;
84-
85-
tls::with_opt(|opt_tcx| {
86-
if let Some(tcx) = opt_tcx {
87-
if let Some(def_id) = node.extract_def_id(tcx) {
88-
write!(f, "{}", tcx.def_path_debug_str(def_id))?;
89-
} else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(node) {
90-
write!(f, "{s}")?;
91-
} else {
92-
write!(f, "{}", node.hash)?;
93-
}
94-
} else {
95-
write!(f, "{}", node.hash)?;
96-
}
97-
Ok(())
98-
})?;
99-
100-
write!(f, ")")
101-
}
102-
10367
/// Sets up the callbacks in prior crates which we want to refer to the
10468
/// TyCtxt in.
10569
pub fn setup_callbacks() {
10670
rustc_span::SPAN_TRACK.swap(&(track_span_parent as fn(_)));
10771
rustc_hir::def_id::DEF_ID_DEBUG.swap(&(def_id_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
108-
rustc_middle::dep_graph::dep_node::DEP_KIND_DEBUG
109-
.swap(&(dep_kind_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
110-
rustc_middle::dep_graph::dep_node::DEP_NODE_DEBUG
111-
.swap(&(dep_node_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
112-
TRACK_DIAGNOSTIC.swap(&(track_diagnostic as _));
72+
rustc_errors::TRACK_DIAGNOSTIC.swap(&(track_diagnostic as _));
11373
}

compiler/rustc_macros/src/hash_stable.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ fn hash_stable_derive_with_mode(
9696

9797
let context: syn::Type = match mode {
9898
HashStableMode::Normal => {
99-
parse_quote!(::rustc_query_system::ich::StableHashingContext<'__ctx>)
99+
parse_quote!(::rustc_middle::ich::StableHashingContext<'__ctx>)
100100
}
101101
HashStableMode::Generic | HashStableMode::NoContext => parse_quote!(__CTX),
102102
};

compiler/rustc_middle/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ rustc_hir_pretty = { path = "../rustc_hir_pretty" }
2626
rustc_index = { path = "../rustc_index" }
2727
rustc_lint_defs = { path = "../rustc_lint_defs" }
2828
rustc_macros = { path = "../rustc_macros" }
29-
rustc_query_system = { path = "../rustc_query_system" }
3029
rustc_serialize = { path = "../rustc_serialize" }
3130
rustc_session = { path = "../rustc_session" }
3231
rustc_span = { path = "../rustc_span" }

compiler/rustc_middle/src/dep_graph/dep_node.rs

Lines changed: 27 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -58,18 +58,17 @@
5858
use std::fmt;
5959
use std::hash::Hash;
6060

61-
use rustc_data_structures::AtomicRef;
6261
use rustc_data_structures::fingerprint::{Fingerprint, PackedFingerprint};
6362
use rustc_data_structures::stable_hasher::{HashStable, StableHasher, StableOrd, ToStableHashKey};
6463
use rustc_hir::def_id::DefId;
6564
use rustc_hir::definitions::DefPathHash;
6665
use rustc_macros::{Decodable, Encodable};
67-
use rustc_query_system::ich::StableHashingContext;
6866
use rustc_span::Symbol;
6967

7068
use super::{FingerprintStyle, SerializedDepNodeIndex};
69+
use crate::ich::StableHashingContext;
7170
use crate::mir::mono::MonoItem;
72-
use crate::ty::TyCtxt;
71+
use crate::ty::{TyCtxt, tls};
7372

7473
/// This serves as an index into arrays built by `make_dep_kind_array`.
7574
#[derive(Clone, Copy, PartialEq, Eq, Hash)]
@@ -114,16 +113,15 @@ impl DepKind {
114113
pub(crate) const MAX: u16 = DEP_KIND_VARIANTS - 1;
115114
}
116115

117-
pub fn default_dep_kind_debug(kind: DepKind, f: &mut fmt::Formatter<'_>) -> fmt::Result {
118-
f.debug_struct("DepKind").field("variant", &kind.variant).finish()
119-
}
120-
121-
pub static DEP_KIND_DEBUG: AtomicRef<fn(DepKind, &mut fmt::Formatter<'_>) -> fmt::Result> =
122-
AtomicRef::new(&(default_dep_kind_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
123-
124116
impl fmt::Debug for DepKind {
125117
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
126-
(*DEP_KIND_DEBUG)(*self, f)
118+
tls::with_opt(|opt_tcx| {
119+
if let Some(tcx) = opt_tcx {
120+
write!(f, "{}", tcx.dep_kind_vtable(*self).name)
121+
} else {
122+
f.debug_struct("DepKind").field("variant", &self.variant).finish()
123+
}
124+
})
127125
}
128126
}
129127

@@ -175,16 +173,26 @@ impl DepNode {
175173
}
176174
}
177175

178-
pub fn default_dep_node_debug(node: DepNode, f: &mut fmt::Formatter<'_>) -> fmt::Result {
179-
f.debug_struct("DepNode").field("kind", &node.kind).field("hash", &node.hash).finish()
180-
}
181-
182-
pub static DEP_NODE_DEBUG: AtomicRef<fn(DepNode, &mut fmt::Formatter<'_>) -> fmt::Result> =
183-
AtomicRef::new(&(default_dep_node_debug as fn(_, &mut fmt::Formatter<'_>) -> _));
184-
185176
impl fmt::Debug for DepNode {
186177
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
187-
(*DEP_NODE_DEBUG)(*self, f)
178+
write!(f, "{:?}(", self.kind)?;
179+
180+
tls::with_opt(|opt_tcx| {
181+
if let Some(tcx) = opt_tcx {
182+
if let Some(def_id) = self.extract_def_id(tcx) {
183+
write!(f, "{}", tcx.def_path_debug_str(def_id))?;
184+
} else if let Some(ref s) = tcx.dep_graph.dep_node_debug_str(*self) {
185+
write!(f, "{s}")?;
186+
} else {
187+
write!(f, "{}", self.hash)?;
188+
}
189+
} else {
190+
write!(f, "{}", self.hash)?;
191+
}
192+
Ok(())
193+
})?;
194+
195+
write!(f, ")")
188196
}
189197
}
190198

compiler/rustc_middle/src/dep_graph/graph.rs

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,6 @@ use rustc_data_structures::{assert_matches, outline};
1515
use rustc_errors::DiagInner;
1616
use rustc_index::IndexVec;
1717
use rustc_macros::{Decodable, Encodable};
18-
use rustc_query_system::ich::StableHashingContext;
19-
use rustc_query_system::query::QuerySideEffect;
2018
use rustc_serialize::opaque::{FileEncodeResult, FileEncoder};
2119
use rustc_session::Session;
2220
use tracing::{debug, instrument};
@@ -27,9 +25,27 @@ use super::query::DepGraphQuery;
2725
use super::serialized::{GraphEncoder, SerializedDepGraph, SerializedDepNodeIndex};
2826
use super::{DepKind, DepNode, HasDepContext, WorkProductId, read_deps, with_deps};
2927
use crate::dep_graph::edges::EdgesVec;
28+
use crate::ich::StableHashingContext;
3029
use crate::ty::TyCtxt;
3130
use crate::verify_ich::incremental_verify_ich;
3231

32+
/// Tracks 'side effects' for a particular query.
33+
/// This struct is saved to disk along with the query result,
34+
/// and loaded from disk if we mark the query as green.
35+
/// This allows us to 'replay' changes to global state
36+
/// that would otherwise only occur if we actually
37+
/// executed the query method.
38+
///
39+
/// Each side effect gets an unique dep node index which is added
40+
/// as a dependency of the query which had the effect.
41+
#[derive(Debug, Encodable, Decodable)]
42+
pub enum QuerySideEffect {
43+
/// Stores a diagnostic emitted during query execution.
44+
/// This diagnostic will be re-emitted if we mark
45+
/// the query as green, as that query will have the side
46+
/// effect dep node as a dependency.
47+
Diagnostic(DiagInner),
48+
}
3349
#[derive(Clone)]
3450
pub struct DepGraph {
3551
data: Option<Arc<DepGraphData>>,

compiler/rustc_middle/src/dep_graph/mod.rs

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,8 @@ pub use self::dep_node::{
77
label_strs,
88
};
99
pub use self::graph::{
10-
DepGraph, DepGraphData, DepNodeIndex, TaskDepsRef, WorkProduct, WorkProductMap, hash_result,
10+
DepGraph, DepGraphData, DepNodeIndex, QuerySideEffect, TaskDepsRef, WorkProduct,
11+
WorkProductMap, hash_result,
1112
};
1213
use self::graph::{MarkFrame, print_markframe_trace};
1314
pub use self::query::DepGraphQuery;
File renamed without changes.

compiler/rustc_query_system/src/ich/impls_syntax.rs renamed to compiler/rustc_middle/src/ich/impls_syntax.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use rustc_span::{SourceFile, Symbol, sym};
66
use smallvec::SmallVec;
77
use {rustc_ast as ast, rustc_hir as hir};
88

9-
use crate::ich::StableHashingContext;
9+
use super::StableHashingContext;
1010

1111
impl<'a> HashStable<StableHashingContext<'a>> for ast::NodeId {
1212
#[inline]

0 commit comments

Comments
 (0)