Skip to content

Commit d2eacf6

Browse files
committed
Rename all-query functions.
There are four functions that use `for_each_query_vtable!` to call an "inner" function. They are: - collect_active_jobs_from_all_queries -> gather_active_jobs - alloc_self_profile_query_strings -> alloc_self_profile_query_strings_for_query_cache - encode_all_query_results -> encode_query_results - query_key_hash_verify_all -> query_key_hash_verify These names are all over the place. This commit renames them as follows: - collect_active_query_jobs{,_inner} - alloc_self_profile_query_strings{,_inner} - encode_query_values{,_inner} - verify_query_key_hashes{,_inner} This: - puts the verb at the start - uses "inner" for all the inners (which makes sense now that the inners are all next to their callers) - uses `_query_` consistently - avoids `all`, because the plurals are enough - uses `values` instead of `results` - removes the `collect`/`gather` distinction, which is no longer important
1 parent d27207d commit d2eacf6

9 files changed

Lines changed: 29 additions & 30 deletions

File tree

compiler/rustc_interface/src/util.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ use rustc_data_structures::sync;
1818
use rustc_metadata::{DylibError, EncodedMetadata, load_symbol_from_dylib};
1919
use rustc_middle::dep_graph::{WorkProduct, WorkProductId};
2020
use rustc_middle::ty::{CurrentGcx, TyCtxt};
21-
use rustc_query_impl::{CollectActiveJobsKind, collect_active_jobs_from_all_queries};
21+
use rustc_query_impl::{CollectActiveJobsKind, collect_active_query_jobs};
2222
use rustc_session::config::{
2323
Cfg, CrateType, OutFileName, OutputFilenames, OutputTypes, Sysroot, host_tuple,
2424
};
@@ -255,7 +255,7 @@ internal compiler error: query cycle handler thread panicked, aborting process";
255255
// Ensure there were no errors collecting all active jobs.
256256
// We need the complete map to ensure we find a cycle to
257257
// break.
258-
collect_active_jobs_from_all_queries(
258+
collect_active_query_jobs(
259259
tcx,
260260
CollectActiveJobsKind::FullNoContention,
261261
)

compiler/rustc_middle/src/hooks/mod.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,7 @@ declare_hooks! {
9898
/// Trying to execute a query afterwards would attempt to read the result cache we just dropped.
9999
hook save_dep_graph() -> ();
100100

101-
hook query_key_hash_verify_all() -> ();
101+
hook verify_query_key_hashes() -> ();
102102

103103
/// Ensure the given scalar is valid for the given type.
104104
/// This checks non-recursive runtime validity.
@@ -109,7 +109,7 @@ declare_hooks! {
109109
/// Creates the MIR for a given `DefId`, including unreachable code.
110110
hook build_mir_inner_impl(def: LocalDefId) -> mir::Body<'tcx>;
111111

112-
hook encode_all_query_results(
112+
hook encode_query_values(
113113
encoder: &mut CacheEncoder<'_, 'tcx>,
114114
query_result_index: &mut EncodedDepNodeIndex
115115
) -> ();

compiler/rustc_middle/src/query/on_disk_cache.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -246,10 +246,10 @@ impl OnDiskCache {
246246
// Encode query results.
247247
let mut query_result_index = EncodedDepNodeIndex::new();
248248

249-
tcx.sess.time("encode_query_results", || {
249+
tcx.sess.time("encode_query_values", || {
250250
let enc = &mut encoder;
251251
let qri = &mut query_result_index;
252-
tcx.encode_all_query_results(enc, qri);
252+
tcx.encode_query_values(enc, qri);
253253
});
254254

255255
// Encode side effects.

compiler/rustc_middle/src/ty/context.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1678,7 +1678,7 @@ impl<'tcx> TyCtxt<'tcx> {
16781678
self.alloc_self_profile_query_strings();
16791679

16801680
self.save_dep_graph();
1681-
self.query_key_hash_verify_all();
1681+
self.verify_query_key_hashes();
16821682

16831683
if let Err((path, error)) = self.dep_graph.finish_encoding() {
16841684
self.sess.dcx().emit_fatal(crate::error::FailedWritingFile { path: &path, error });

compiler/rustc_query_impl/src/execution.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -56,14 +56,14 @@ pub enum CollectActiveJobsKind {
5656
/// Prefer passing `false` to `require_complete` to avoid potential deadlocks,
5757
/// especially when called from within a deadlock handler, unless a
5858
/// complete map is needed and no deadlock is possible at this call site.
59-
pub fn collect_active_jobs_from_all_queries<'tcx>(
59+
pub fn collect_active_query_jobs<'tcx>(
6060
tcx: TyCtxt<'tcx>,
6161
collect_kind: CollectActiveJobsKind,
6262
) -> QueryJobMap<'tcx> {
6363
let mut job_map = QueryJobMap::default();
6464

6565
for_each_query_vtable!(ALL, tcx, |query| {
66-
gather_active_jobs(query, collect_kind, &mut job_map);
66+
collect_active_query_jobs_inner(query, collect_kind, &mut job_map);
6767
});
6868

6969
job_map
@@ -78,7 +78,7 @@ pub fn collect_active_jobs_from_all_queries<'tcx>(
7878
/// grep for.)
7979
///
8080
/// Aborts if jobs can't be gathered as specified by `collect_kind`.
81-
fn gather_active_jobs<'tcx, C>(
81+
fn collect_active_query_jobs_inner<'tcx, C>(
8282
query: &'tcx QueryVTable<'tcx, C>,
8383
collect_kind: CollectActiveJobsKind,
8484
job_map: &mut QueryJobMap<'tcx>,
@@ -218,8 +218,7 @@ fn cycle_error<'tcx, C: QueryCache>(
218218
) -> (C::Value, Option<DepNodeIndex>) {
219219
// Ensure there were no errors collecting all active jobs.
220220
// We need the complete map to ensure we find a cycle to break.
221-
let job_map =
222-
collect_active_jobs_from_all_queries(tcx, CollectActiveJobsKind::FullNoContention);
221+
let job_map = collect_active_query_jobs(tcx, CollectActiveJobsKind::FullNoContention);
223222

224223
let error = find_cycle_in_stack(try_execute, job_map, &current_query_job(), span);
225224
(mk_cycle(query, tcx, key, error), None)

compiler/rustc_query_impl/src/job.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@ use rustc_middle::query::{
1212
use rustc_middle::ty::TyCtxt;
1313
use rustc_span::{DUMMY_SP, Span};
1414

15-
use crate::{CollectActiveJobsKind, collect_active_jobs_from_all_queries};
15+
use crate::{CollectActiveJobsKind, collect_active_query_jobs};
1616

1717
/// Map from query job IDs to job information collected by
18-
/// `collect_active_jobs_from_all_queries`.
18+
/// `collect_active_query_jobs`.
1919
#[derive(Debug, Default)]
2020
pub struct QueryJobMap<'tcx> {
2121
map: FxHashMap<QueryJobId, QueryJobInfo<'tcx>>,
@@ -24,7 +24,7 @@ pub struct QueryJobMap<'tcx> {
2424
impl<'tcx> QueryJobMap<'tcx> {
2525
/// Adds information about a job ID to the job map.
2626
///
27-
/// Should only be called by `gather_active_jobs`.
27+
/// Should only be called by `collect_active_query_jobs_inner`.
2828
pub(crate) fn insert(&mut self, id: QueryJobId, info: QueryJobInfo<'tcx>) {
2929
self.map.insert(id, info);
3030
}
@@ -407,7 +407,7 @@ pub fn print_query_stack<'tcx>(
407407
let mut count_total = 0;
408408

409409
// Make use of a partial query job map if we fail to take locks collecting active queries.
410-
let job_map = collect_active_jobs_from_all_queries(tcx, CollectActiveJobsKind::PartialAllowed);
410+
let job_map = collect_active_query_jobs(tcx, CollectActiveJobsKind::PartialAllowed);
411411

412412
if let Some(ref mut file) = file {
413413
let _ = writeln!(file, "\n\nquery stack during panic:");

compiler/rustc_query_impl/src/lib.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ use rustc_middle::query::plumbing::{QuerySystem, QueryVTable};
1717
use rustc_middle::ty::TyCtxt;
1818

1919
pub use crate::dep_kind_vtables::make_dep_kind_vtables;
20-
pub use crate::execution::{CollectActiveJobsKind, collect_active_jobs_from_all_queries};
20+
pub use crate::execution::{CollectActiveJobsKind, collect_active_query_jobs};
2121
pub use crate::job::{QueryJobMap, break_query_cycles, print_query_stack};
2222

2323
mod dep_kind_vtables;
@@ -64,6 +64,6 @@ pub fn query_system<'tcx>(
6464
pub fn provide(providers: &mut rustc_middle::util::Providers) {
6565
providers.hooks.alloc_self_profile_query_strings =
6666
profiling_support::alloc_self_profile_query_strings;
67-
providers.hooks.query_key_hash_verify_all = plumbing::query_key_hash_verify_all;
68-
providers.hooks.encode_all_query_results = plumbing::encode_all_query_results;
67+
providers.hooks.verify_query_key_hashes = plumbing::verify_query_key_hashes;
68+
providers.hooks.encode_query_values = plumbing::encode_query_values;
6969
}

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,10 @@ use crate::error::{QueryOverflow, QueryOverflowNote};
2626
use crate::execution::{all_inactive, force_query};
2727
use crate::job::find_dep_kind_root;
2828
use crate::query_impl::for_each_query_vtable;
29-
use crate::{CollectActiveJobsKind, GetQueryVTable, collect_active_jobs_from_all_queries};
29+
use crate::{CollectActiveJobsKind, GetQueryVTable, collect_active_query_jobs};
3030

3131
fn depth_limit_error<'tcx>(tcx: TyCtxt<'tcx>, job: QueryJobId) {
32-
let job_map = collect_active_jobs_from_all_queries(tcx, CollectActiveJobsKind::Full);
32+
let job_map = collect_active_query_jobs(tcx, CollectActiveJobsKind::Full);
3333
let (span, desc, depth) = find_dep_kind_root(tcx, job, job_map);
3434

3535
let suggested_limit = match tcx.recursion_limit() {
@@ -99,17 +99,17 @@ where
9999
}
100100
}
101101

102-
pub(crate) fn encode_all_query_results<'tcx>(
102+
pub(crate) fn encode_query_values<'tcx>(
103103
tcx: TyCtxt<'tcx>,
104104
encoder: &mut CacheEncoder<'_, 'tcx>,
105105
query_result_index: &mut EncodedDepNodeIndex,
106106
) {
107107
for_each_query_vtable!(CACHE_ON_DISK, tcx, |query| {
108-
encode_query_results(tcx, query, encoder, query_result_index)
108+
encode_query_values_inner(tcx, query, encoder, query_result_index)
109109
});
110110
}
111111

112-
fn encode_query_results<'a, 'tcx, C, V>(
112+
fn encode_query_values_inner<'a, 'tcx, C, V>(
113113
tcx: TyCtxt<'tcx>,
114114
query: &'tcx QueryVTable<'tcx, C>,
115115
encoder: &mut CacheEncoder<'a, 'tcx>,
@@ -135,17 +135,17 @@ fn encode_query_results<'a, 'tcx, C, V>(
135135
});
136136
}
137137

138-
pub(crate) fn query_key_hash_verify_all<'tcx>(tcx: TyCtxt<'tcx>) {
138+
pub(crate) fn verify_query_key_hashes<'tcx>(tcx: TyCtxt<'tcx>) {
139139
if tcx.sess.opts.unstable_opts.incremental_verify_ich || cfg!(debug_assertions) {
140-
tcx.sess.time("query_key_hash_verify_all", || {
140+
tcx.sess.time("verify_query_key_hashes", || {
141141
for_each_query_vtable!(ALL, tcx, |query| {
142-
query_key_hash_verify(query, tcx);
142+
verify_query_key_hashes_inner(query, tcx);
143143
});
144144
});
145145
}
146146
}
147147

148-
fn query_key_hash_verify<'tcx, C: QueryCache>(
148+
fn verify_query_key_hashes_inner<'tcx, C: QueryCache>(
149149
query: &'tcx QueryVTable<'tcx, C>,
150150
tcx: TyCtxt<'tcx>,
151151
) {

compiler/rustc_query_impl/src/profiling_support.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ pub(crate) fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
192192
let mut string_cache = QueryKeyStringCache::new();
193193

194194
for_each_query_vtable!(ALL, tcx, |query| {
195-
alloc_self_profile_query_strings_for_query_cache(tcx, query, &mut string_cache);
195+
alloc_self_profile_query_strings_inner(tcx, query, &mut string_cache);
196196
});
197197

198198
tcx.sess.prof.store_query_cache_hits();
@@ -201,7 +201,7 @@ pub(crate) fn alloc_self_profile_query_strings(tcx: TyCtxt<'_>) {
201201
/// Allocate the self-profiling query strings for a single query cache. This
202202
/// method is called from `alloc_self_profile_query_strings` which knows all
203203
/// the queries via macro magic.
204-
fn alloc_self_profile_query_strings_for_query_cache<'tcx, C>(
204+
fn alloc_self_profile_query_strings_inner<'tcx, C>(
205205
tcx: TyCtxt<'tcx>,
206206
query: &'tcx QueryVTable<'tcx, C>,
207207
string_cache: &mut QueryKeyStringCache,

0 commit comments

Comments
 (0)