Skip to content

Commit 761cc7e

Browse files
authored
Unrolled build for #153078
Rollup merge of #153078 - nnethercote:rm-QuerySystemFns, r=petrochenkov Remove `QuerySystemFns` Two small query-related cleanups. r? petrochenkov
2 parents 1ed4882 + 608d85f commit 761cc7e

File tree

5 files changed

+29
-31
lines changed

5 files changed

+29
-31
lines changed

‎compiler/rustc_middle/src/hooks/mod.rs‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ use rustc_span::def_id::{CrateNum, LocalDefId};
99
use rustc_span::{ExpnHash, ExpnId};
1010

1111
use crate::mir;
12+
use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex};
1213
use crate::ty::{Ty, TyCtxt};
1314

1415
macro_rules! declare_hooks {
@@ -107,6 +108,13 @@ declare_hooks! {
107108
///
108109
/// Creates the MIR for a given `DefId`, including unreachable code.
109110
hook build_mir_inner_impl(def: LocalDefId) -> mir::Body<'tcx>;
111+
112+
hook try_mark_green(dep_node: &crate::dep_graph::DepNode) -> bool;
113+
114+
hook encode_all_query_results(
115+
encoder: &mut CacheEncoder<'_, 'tcx>,
116+
query_result_index: &mut EncodedDepNodeIndex
117+
) -> ();
110118
}
111119

112120
#[cold]

‎compiler/rustc_middle/src/query/on_disk_cache.rs‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use std::collections::hash_map::Entry;
2-
use std::mem;
32
use std::sync::Arc;
3+
use std::{fmt, mem};
44

55
use rustc_data_structures::fx::{FxHashMap, FxIndexMap, FxIndexSet};
66
use rustc_data_structures::memmap::Mmap;
@@ -261,7 +261,7 @@ impl OnDiskCache {
261261
tcx.sess.time("encode_query_results", || {
262262
let enc = &mut encoder;
263263
let qri = &mut query_result_index;
264-
(tcx.query_system.fns.encode_query_results)(tcx, enc, qri);
264+
tcx.encode_all_query_results(enc, qri);
265265
});
266266

267267
// Encode side effects.
@@ -508,7 +508,7 @@ impl<'a, 'tcx> CacheDecoder<'a, 'tcx> {
508508
// tag matches and the correct amount of bytes was read.
509509
fn decode_tagged<D, T, V>(decoder: &mut D, expected_tag: T) -> V
510510
where
511-
T: Decodable<D> + Eq + std::fmt::Debug,
511+
T: Decodable<D> + Eq + fmt::Debug,
512512
V: Decodable<D>,
513513
D: Decoder,
514514
{
@@ -829,6 +829,13 @@ pub struct CacheEncoder<'a, 'tcx> {
829829
symbol_index_table: FxHashMap<u32, usize>,
830830
}
831831

832+
impl<'a, 'tcx> fmt::Debug for CacheEncoder<'a, 'tcx> {
833+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
834+
// Add more details here if/when necessary.
835+
f.write_str("CacheEncoder")
836+
}
837+
}
838+
832839
impl<'a, 'tcx> CacheEncoder<'a, 'tcx> {
833840
#[inline]
834841
fn source_file_index(&mut self, source_file: Arc<SourceFile>) -> SourceFileIndex {

‎compiler/rustc_middle/src/query/plumbing.rs‎

Lines changed: 3 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,10 @@ use rustc_macros::HashStable;
1111
use rustc_span::{ErrorGuaranteed, Span};
1212
pub use sealed::IntoQueryParam;
1313

14-
use crate::dep_graph;
1514
use crate::dep_graph::{DepKind, DepNode, DepNodeIndex, SerializedDepNodeIndex};
1615
use crate::ich::StableHashingContext;
1716
use crate::queries::{ExternProviders, Providers, QueryArenas, QueryVTables};
18-
use crate::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
17+
use crate::query::on_disk_cache::OnDiskCache;
1918
use crate::query::stack::{QueryStackDeferred, QueryStackFrame, QueryStackFrameExtra};
2019
use crate::query::{QueryCache, QueryInfo, QueryJob};
2120
use crate::ty::TyCtxt;
@@ -216,17 +215,6 @@ impl<'tcx, C: QueryCache> QueryVTable<'tcx, C> {
216215
}
217216
}
218217

219-
pub struct QuerySystemFns {
220-
pub local_providers: Providers,
221-
pub extern_providers: ExternProviders,
222-
pub encode_query_results: for<'tcx> fn(
223-
tcx: TyCtxt<'tcx>,
224-
encoder: &mut CacheEncoder<'_, 'tcx>,
225-
query_result_index: &mut EncodedDepNodeIndex,
226-
),
227-
pub try_mark_green: for<'tcx> fn(tcx: TyCtxt<'tcx>, dep_node: &dep_graph::DepNode) -> bool,
228-
}
229-
230218
pub struct QuerySystem<'tcx> {
231219
pub arenas: WorkerLocal<QueryArenas<'tcx>>,
232220
pub query_vtables: QueryVTables<'tcx>,
@@ -237,7 +225,8 @@ pub struct QuerySystem<'tcx> {
237225
/// This is `None` if we are not incremental compilation mode
238226
pub on_disk_cache: Option<OnDiskCache>,
239227

240-
pub fns: QuerySystemFns,
228+
pub local_providers: Providers,
229+
pub extern_providers: ExternProviders,
241230

242231
pub jobs: AtomicU64,
243232
}
@@ -327,10 +316,6 @@ impl<'tcx> TyCtxt<'tcx> {
327316
pub fn at(self, span: Span) -> TyCtxtAt<'tcx> {
328317
TyCtxtAt { tcx: self, span }
329318
}
330-
331-
pub fn try_mark_green(self, dep_node: &dep_graph::DepNode) -> bool {
332-
(self.query_system.fns.try_mark_green)(self, dep_node)
333-
}
334319
}
335320

336321
macro_rules! query_helper_param_ty {

‎compiler/rustc_query_impl/src/lib.rs‎

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@ use rustc_data_structures::sync::AtomicU64;
1212
use rustc_middle::dep_graph;
1313
use rustc_middle::queries::{self, ExternProviders, Providers};
1414
use rustc_middle::query::on_disk_cache::{CacheEncoder, EncodedDepNodeIndex, OnDiskCache};
15-
use rustc_middle::query::plumbing::{QuerySystem, QuerySystemFns, QueryVTable};
15+
use rustc_middle::query::plumbing::{QuerySystem, QueryVTable};
1616
use rustc_middle::query::{AsLocalKey, QueryCache, QueryMode};
1717
use rustc_middle::ty::TyCtxt;
1818
use rustc_span::Span;
@@ -59,12 +59,8 @@ pub fn query_system<'tcx>(
5959
arenas: Default::default(),
6060
query_vtables: make_query_vtables(incremental),
6161
on_disk_cache,
62-
fns: QuerySystemFns {
63-
local_providers,
64-
extern_providers,
65-
encode_query_results: encode_all_query_results,
66-
try_mark_green,
67-
},
62+
local_providers,
63+
extern_providers,
6864
jobs: AtomicU64::new(1),
6965
}
7066
}
@@ -74,4 +70,6 @@ rustc_middle::rustc_with_all_queries! { define_queries! }
7470
pub fn provide(providers: &mut rustc_middle::util::Providers) {
7571
providers.hooks.alloc_self_profile_query_strings = alloc_self_profile_query_strings;
7672
providers.hooks.query_key_hash_verify_all = query_key_hash_verify_all;
73+
providers.hooks.encode_all_query_results = encode_all_query_results;
74+
providers.hooks.try_mark_green = try_mark_green;
7775
}

‎compiler/rustc_query_impl/src/plumbing.rs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -226,13 +226,13 @@ macro_rules! hash_result {
226226

227227
macro_rules! call_provider {
228228
([][$tcx:expr, $name:ident, $key:expr]) => {{
229-
($tcx.query_system.fns.local_providers.$name)($tcx, $key)
229+
($tcx.query_system.local_providers.$name)($tcx, $key)
230230
}};
231231
([(separate_provide_extern) $($rest:tt)*][$tcx:expr, $name:ident, $key:expr]) => {{
232232
if let Some(key) = $key.as_local_key() {
233-
($tcx.query_system.fns.local_providers.$name)($tcx, key)
233+
($tcx.query_system.local_providers.$name)($tcx, key)
234234
} else {
235-
($tcx.query_system.fns.extern_providers.$name)($tcx, $key)
235+
($tcx.query_system.extern_providers.$name)($tcx, $key)
236236
}
237237
}};
238238
([$other:tt $($modifiers:tt)*][$($args:tt)*]) => {

0 commit comments

Comments
 (0)