Skip to content

Commit 286acc2

Browse files
committed
Put more things into mod query_impl.
`define_queries!` currently outputs some things (including one `mod $name` per query) into a module `query_impl`, and some things into the crate root. This commit moves the latter things into `query_impl`. This is (a) nicer, and (b) more closely matches what `define_callbacks!` does.
1 parent 8abfc7c commit 286acc2

4 files changed

Lines changed: 15 additions & 11 deletions

File tree

compiler/rustc_query_impl/src/execution.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,9 @@ use rustc_middle::verify_ich::incremental_verify_ich;
1717
use rustc_span::{DUMMY_SP, Span};
1818

1919
use crate::dep_graph::{DepNode, DepNodeIndex};
20-
use crate::for_each_query_vtable;
2120
use crate::job::{QueryJobInfo, QueryJobMap, find_cycle_in_stack, report_cycle};
2221
use crate::plumbing::{current_query_job, next_job_id, start_query};
22+
use crate::query_impl::for_each_query_vtable;
2323

2424
#[inline]
2525
fn equivalent_key<K: Eq, V>(k: K) -> impl Fn(&(K, V)) -> bool {

compiler/rustc_query_impl/src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ pub fn query_system<'tcx>(
5151
on_disk_cache: Option<OnDiskCache>,
5252
incremental: bool,
5353
) -> QuerySystem<'tcx> {
54-
let mut query_vtables = make_query_vtables(incremental);
54+
let mut query_vtables = query_impl::make_query_vtables(incremental);
5555
from_cycle_error::specialize_query_vtables(&mut query_vtables);
5656
QuerySystem {
5757
arenas: Default::default(),

compiler/rustc_query_impl/src/plumbing.rs

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,8 @@ use rustc_span::def_id::LOCAL_CRATE;
3333
use crate::error::{QueryOverflow, QueryOverflowNote};
3434
use crate::execution::{all_inactive, force_query};
3535
use crate::job::find_dep_kind_root;
36-
use crate::{GetQueryVTable, collect_active_jobs_from_all_queries, for_each_query_vtable};
36+
use crate::query_impl::for_each_query_vtable;
37+
use crate::{GetQueryVTable, collect_active_jobs_from_all_queries};
3738

3839
fn depth_limit_error<'tcx>(tcx: TyCtxt<'tcx>, job: QueryJobId) {
3940
let job_map =
@@ -350,7 +351,7 @@ macro_rules! define_queries {
350351
non_queries { $($_:tt)* }
351352
) => {
352353
pub(crate) mod query_impl { $(pub(crate) mod $name {
353-
use super::super::*;
354+
use super::*;
354355
use rustc_middle::query::erase::{self, Erased};
355356

356357
// It seems to be important that every query has its own monomorphic
@@ -361,8 +362,9 @@ macro_rules! define_queries {
361362
pub(crate) mod execute_query_incr {
362363
use super::*;
363364

364-
// Adding `__rust_end_short_backtrace` marker to backtraces so that we emit the frames
365-
// when `RUST_BACKTRACE=1`, add a new mod with `$name` here is to allow duplicate naming
365+
// Adding `__rust_end_short_backtrace` marker to backtraces so that we emit the
366+
// frames when `RUST_BACKTRACE=1`, add a new mod with `$name` here is to allow
367+
// duplicate naming.
366368
#[inline(never)]
367369
pub(crate) fn __rust_end_short_backtrace<'tcx>(
368370
tcx: TyCtxt<'tcx>,
@@ -526,14 +528,16 @@ macro_rules! define_queries {
526528
&tcx.query_system.query_vtables.$name
527529
}
528530
}
529-
})*}
531+
})*
530532

531-
pub fn make_query_vtables<'tcx>(incremental: bool)
533+
use super::*;
534+
535+
pub(crate) fn make_query_vtables<'tcx>(incremental: bool)
532536
-> rustc_middle::queries::QueryVTables<'tcx>
533537
{
534538
rustc_middle::queries::QueryVTables {
535539
$(
536-
$name: query_impl::$name::make_query_vtable(incremental),
540+
$name: $name::make_query_vtable(incremental),
537541
)*
538542
}
539543
}
@@ -581,5 +585,5 @@ macro_rules! define_queries {
581585
}
582586

583587
pub(crate) use for_each_query_vtable;
584-
}
588+
}}
585589
}

compiler/rustc_query_impl/src/profiling_support.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ use rustc_middle::query::QueryCache;
1010
use rustc_middle::query::plumbing::QueryVTable;
1111
use rustc_middle::ty::TyCtxt;
1212

13-
use crate::for_each_query_vtable;
13+
use crate::query_impl::for_each_query_vtable;
1414

1515
pub(crate) struct QueryKeyStringCache {
1616
def_id_cache: FxHashMap<DefId, StringId>,

0 commit comments

Comments
 (0)