Merge some query impl modules into one
This commit is contained in:
parent
d3f416dc06
commit
9e755d98cc
1 changed files with 126 additions and 144 deletions
|
@ -506,14 +506,16 @@ macro_rules! define_queries {
|
|||
(
|
||||
$($(#[$attr:meta])*
|
||||
[$($modifiers:tt)*] fn $name:ident($($K:tt)*) -> $V:ty,)*) => {
|
||||
mod get_query_incr {
|
||||
|
||||
pub(crate) mod query_impl { $(pub mod $name {
|
||||
use super::super::*;
|
||||
use std::marker::PhantomData;
|
||||
|
||||
pub mod get_query_incr {
|
||||
use super::*;
|
||||
|
||||
$(
|
||||
// Adding `__rust_end_short_backtrace` marker to backtraces so that we emit the frames
|
||||
// when `RUST_BACKTRACE=1`, add a new mod with `$name` here is to allow duplicate naming
|
||||
pub mod $name {
|
||||
use super::*;
|
||||
#[inline(never)]
|
||||
pub fn __rust_end_short_backtrace<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -522,7 +524,7 @@ macro_rules! define_queries {
|
|||
mode: QueryMode,
|
||||
) -> Option<Erase<queries::$name::Value<'tcx>>> {
|
||||
get_query_incr(
|
||||
query_config::$name::config(tcx),
|
||||
QueryType::config(tcx),
|
||||
QueryCtxt::new(tcx),
|
||||
span,
|
||||
key,
|
||||
|
@ -530,15 +532,10 @@ macro_rules! define_queries {
|
|||
)
|
||||
}
|
||||
}
|
||||
)*
|
||||
}
|
||||
|
||||
mod get_query_non_incr {
|
||||
pub mod get_query_non_incr {
|
||||
use super::*;
|
||||
|
||||
$(
|
||||
pub mod $name {
|
||||
use super::*;
|
||||
#[inline(never)]
|
||||
pub fn __rust_end_short_backtrace<'tcx>(
|
||||
tcx: TyCtxt<'tcx>,
|
||||
|
@ -547,46 +544,15 @@ macro_rules! define_queries {
|
|||
__mode: QueryMode,
|
||||
) -> Option<Erase<queries::$name::Value<'tcx>>> {
|
||||
Some(get_query_non_incr(
|
||||
query_config::$name::config(tcx),
|
||||
QueryType::config(tcx),
|
||||
QueryCtxt::new(tcx),
|
||||
span,
|
||||
key,
|
||||
))
|
||||
}
|
||||
}
|
||||
)*
|
||||
}
|
||||
|
||||
pub(crate) fn engine(incremental: bool) -> QueryEngine {
|
||||
if incremental {
|
||||
QueryEngine {
|
||||
$($name: get_query_incr::$name::__rust_end_short_backtrace,)*
|
||||
}
|
||||
} else {
|
||||
QueryEngine {
|
||||
$($name: get_query_non_incr::$name::__rust_end_short_backtrace,)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
mod query_config {
|
||||
use std::marker::PhantomData;
|
||||
|
||||
$(
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub struct $name<'tcx> {
|
||||
data: PhantomData<&'tcx ()>
|
||||
}
|
||||
)*
|
||||
}
|
||||
|
||||
#[allow(nonstandard_style)]
|
||||
mod dynamic_query {
|
||||
use super::*;
|
||||
|
||||
$(
|
||||
pub(super) fn $name<'tcx>() -> DynamicQuery<'tcx, queries::$name::Storage<'tcx>> {
|
||||
pub fn dynamic_query<'tcx>() -> DynamicQuery<'tcx, queries::$name::Storage<'tcx>> {
|
||||
DynamicQuery {
|
||||
name: stringify!($name),
|
||||
eval_always: is_eval_always!([$($modifiers)*]),
|
||||
|
@ -639,10 +605,13 @@ macro_rules! define_queries {
|
|||
format_value: |value| format!("{:?}", restore::<queries::$name::Value<'tcx>>(*value)),
|
||||
}
|
||||
}
|
||||
)*
|
||||
|
||||
#[derive(Copy, Clone, Default)]
|
||||
pub struct QueryType<'tcx> {
|
||||
data: PhantomData<&'tcx ()>
|
||||
}
|
||||
|
||||
$(impl<'tcx> QueryConfigRestored<'tcx> for query_config::$name<'tcx> {
|
||||
impl<'tcx> QueryConfigRestored<'tcx> for QueryType<'tcx> {
|
||||
type RestoredValue = queries::$name::Value<'tcx>;
|
||||
type Config = DynamicConfig<
|
||||
'tcx,
|
||||
|
@ -663,12 +632,25 @@ macro_rules! define_queries {
|
|||
fn restore(value: <Self::Config as QueryConfig<QueryCtxt<'tcx>>>::Value) -> Self::RestoredValue {
|
||||
restore::<queries::$name::Value<'tcx>>(value)
|
||||
}
|
||||
})*
|
||||
}
|
||||
})*}
|
||||
|
||||
pub(crate) fn engine(incremental: bool) -> QueryEngine {
|
||||
if incremental {
|
||||
QueryEngine {
|
||||
$($name: query_impl::$name::get_query_incr::__rust_end_short_backtrace,)*
|
||||
}
|
||||
} else {
|
||||
QueryEngine {
|
||||
$($name: query_impl::$name::get_query_non_incr::__rust_end_short_backtrace,)*
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn dynamic_queries<'tcx>() -> DynamicQueries<'tcx> {
|
||||
DynamicQueries {
|
||||
$(
|
||||
$name: dynamic_query::$name(),
|
||||
$name: query_impl::$name::dynamic_query(),
|
||||
)*
|
||||
}
|
||||
}
|
||||
|
@ -731,7 +713,7 @@ macro_rules! define_queries {
|
|||
}
|
||||
|
||||
$(pub(crate) fn $name<'tcx>()-> DepKindStruct<'tcx> {
|
||||
$crate::plumbing::query_callback::<query_config::$name<'tcx>>(
|
||||
$crate::plumbing::query_callback::<query_impl::$name::QueryType<'tcx>>(
|
||||
is_anon!([$($modifiers)*]),
|
||||
is_eval_always!([$($modifiers)*]),
|
||||
)
|
||||
|
@ -786,8 +768,8 @@ macro_rules! define_queries {
|
|||
)
|
||||
},
|
||||
encode_query_results: expand_if_cached!([$($modifiers)*], |tcx, encoder, query_result_index|
|
||||
$crate::plumbing::encode_query_results::<super::query_config::$name<'tcx>>(
|
||||
super::query_config::$name::config(tcx),
|
||||
$crate::plumbing::encode_query_results::<query_impl::$name::QueryType<'tcx>>(
|
||||
query_impl::$name::QueryType::config(tcx),
|
||||
QueryCtxt::new(tcx),
|
||||
encoder,
|
||||
query_result_index,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue